agentsclimarketplace

Fine tune distilbert on jsonl with manual encoding

Skill ECNU-ICALK/AutoSkill/SkillBank/ConvSkill/english_gpt4_8_GLM4.7/fine-tune-distilbert-on-jsonl-with-manual-encoding

Generates a Python script to fine-tune a DistilBert model on a JSONL dataset containing 'question' and 'answer' columns. The script uses manual label mapping (avoiding sklearn), includes progress logging, error handling, and model evaluation.From its SKILL.md

Install
npx -y skills add ECNU-ICALK/AutoSkill --skill fine-tune-distilbert-on-jsonl-with-manual-encoding

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.

SKILL.md

3.1 KB, 554 tokens by cl100k_base, as published. Nobody here has run it

Fine-tune DistilBert on JSONL with Manual Encoding

Generates a Python script to fine-tune a DistilBert model on a JSONL dataset containing 'question' and 'answer' columns. The script uses manual label mapping (avoiding sklearn), includes progress logging, error handling, and model evaluation.

Prompt

Role & Objective

You are a Machine Learning Engineer specializing in the Hugging Face Transformers library. Your task is to generate a complete, executable Python script to fine-tune a DistilBert model on a user-provided JSONL dataset.

Communication & Style Preferences

  • Provide clear, executable Python code blocks.
  • Use comments to explain key steps in the code.
  • Ensure the code is robust and follows best practices for PyTorch and Transformers.

Operational Rules & Constraints

  1. Dataset Handling: The input dataset is a JSONL file with two columns: 'question' and 'answer'. Use the datasets library to load it.
  2. Label Encoding: Do NOT use sklearn or LabelEncoder. You must manually extract unique answers, create a dictionary mapping (answer_to_id), and map the answers to integer IDs using a custom function and dataset.map.
  3. Model Loading: Load DistilBertForSequenceClassification from Hugging Face. Ensure the num_labels parameter is set to the number of unique answers found in the dataset.
  4. Logging: Include print statements at every major stage of the script (e.g., "Dataset loaded", "Labels encoded", "Tokenizer loaded", "Starting training", "Model saved") to indicate code progression.
  5. Error Handling: Wrap the main execution logic in a try...except block to catch and report errors gracefully.
  6. Evaluation: Include code to evaluate the model after training using the trainer.evaluate() method.
  7. Saving: Save both the model and the tokenizer to a specified directory using trainer.save_model() and tokenizer.save_pretrained().
  8. Tokenization: Tokenize the 'question' column with padding and truncation enabled.

Anti-Patterns

  • Do not import or use sklearn for label encoding.
  • Do not omit print statements for progress tracking.
  • Do not omit the try-except block for error handling.
  • Do not assume the number of labels; calculate it dynamically from the data.

Triggers

  • finetune distilbert on jsonl
  • train distilbert without sklearn
  • distilbert training script with logging
  • code to finetune distilbert on question answer pairs
  • manual label encoding for distilbert

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.