Instructions to use BertilBraun/competency-extraction-finetune with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use BertilBraun/competency-extraction-finetune with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="BertilBraun/competency-extraction-finetune") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("BertilBraun/competency-extraction-finetune", dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use BertilBraun/competency-extraction-finetune with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "BertilBraun/competency-extraction-finetune" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "BertilBraun/competency-extraction-finetune", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/BertilBraun/competency-extraction-finetune
- SGLang
How to use BertilBraun/competency-extraction-finetune with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "BertilBraun/competency-extraction-finetune" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "BertilBraun/competency-extraction-finetune", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "BertilBraun/competency-extraction-finetune" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "BertilBraun/competency-extraction-finetune", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use BertilBraun/competency-extraction-finetune with Docker Model Runner:
docker model run hf.co/BertilBraun/competency-extraction-finetune
Fine-Tuning Process for Competence Extraction of Phi-3-mini-128k-instruct
This document provides an overview of the fine-tuning process described in src/finetuning/ (of github.com/BertilBraun/Master-Thesis) for the competence extraction task. The process involves creating a synthetic custom dataset, training the model using Direct Preference Optimization (DPO), and evaluating the model's performance with both automated metrics and expert verification.
Competence Extraction Task
The objective is to extract detailed competency profiles from textual data, such as abstracts or documents. These profiles represent the skills and knowledge areas related to a specific domain.
Format of the Profiles
The profiles are structured in a standardized format to encapsulate the competencies effectively. An example profile might include:
- Domain: The main area of expertise.
- Competencies: A list of skills or knowledge areas with accompanying descriptions.
Domain: "Data Science"
Competencies:
- Machine Learning: Advanced knowledge of finetuning and training...
- Statistical Analysis: Mathematical modeling etc...
- Data Visualization: Creations of visualizations using MatPlot and Python...
Synthetic Custom Dataset
To train the model, a synthetic dataset is generated with the following components:
- Abstracts: Collections of textual data related to various domains.
- Generated Profiles: Competency profiles created based on the abstracts.
- Preference Samples: Pairs of profiles with annotations indicating which profile better represents the competencies in the given abstracts.
This dataset simulates real-world data and provides the model with diverse examples to learn from.
Training with Direct Preference Optimization (DPO)
The model is fine-tuned using Direct Preference Optimization (DPO), which focuses on optimizing the model based on preference judgments between pairs of outputs.
Training Steps
- Data Preparation: Format the synthetic dataset into prompts and responses suitable for DPO.
- Model Configuration: Initialize the base model and configure training parameters, such as learning rate and batch size.
- Fine-Tuning: Train the model using the DPO algorithm to prefer outputs that better match the desired competencies.
- Evaluation: Assess the model's performance on a validation set to monitor improvement.
LLM as Evaluator
An auxiliary Large Language Model (LLM) is used to evaluate the generated profiles. The LLM assesses the quality and relevance of profiles, providing an automated way to generate preference judgments for training.
Expert Verification
Human experts review a subset of the model's outputs to verify the accuracy and quality of the extracted competencies. This step ensures that the fine-tuned model aligns with domain-specific expectations and provides reliable results.
Performance Metrics
- Preference Over Base Model: The fine-tuned model achieves an 80% preference rate over the base model, indicating significant improvement in extracting relevant competencies.
- Comparison with Larger Models: While improved, the model's performance still lags behind larger models in terms of profile quality, suggesting room for further enhancement.
Conclusion
The fine-tuning process successfully enhances the model's ability to extract competencies from textual data. Combining synthetic datasets, DPO training, and evaluations using both LLMs and expert verification contributes to the model's improved performance.
Model tree for BertilBraun/competency-extraction-finetune
Base model
microsoft/Phi-3-mini-128k-instruct