Update model card with comprehensive documentation
Browse files
README.md
CHANGED
|
@@ -1,65 +1,111 @@
|
|
| 1 |
---
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
tags:
|
| 6 |
-
- llama-factory
|
| 7 |
- lora
|
| 8 |
-
-
|
| 9 |
-
|
| 10 |
-
-
|
| 11 |
-
|
|
|
|
| 12 |
---
|
| 13 |
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
language:
|
| 3 |
+
- en
|
| 4 |
+
license: mit
|
| 5 |
tags:
|
|
|
|
| 6 |
- lora
|
| 7 |
+
- tool-calling
|
| 8 |
+
- llama3
|
| 9 |
+
- instruction-tuning
|
| 10 |
+
- json-generation
|
| 11 |
+
base_model: meta-llama/Meta-Llama-3-8B-Instruct
|
| 12 |
---
|
| 13 |
|
| 14 |
+
# Tool-Calling LoRA for LLaMA-3-8B-Instruct
|
| 15 |
+
|
| 16 |
+
This is a LoRA (Low-Rank Adaptation) model fine-tuned on tool-calling datasets to enhance the model's ability to generate structured JSON responses for tool execution.
|
| 17 |
+
|
| 18 |
+
## Model Details
|
| 19 |
+
|
| 20 |
+
- **Base Model**: meta-llama/Meta-Llama-3-8B-Instruct
|
| 21 |
+
- **Fine-tuning Method**: LoRA (Low-Rank Adaptation)
|
| 22 |
+
- **LoRA Rank**: 16
|
| 23 |
+
- **LoRA Alpha**: 32
|
| 24 |
+
- **Training Dataset**: Custom tool-calling dataset with 357 samples
|
| 25 |
+
- **Training Epochs**: 5
|
| 26 |
+
- **Learning Rate**: 5.0e-5
|
| 27 |
+
|
| 28 |
+
## Usage
|
| 29 |
+
|
| 30 |
+
### Load the Model
|
| 31 |
+
|
| 32 |
+
```python
|
| 33 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 34 |
+
from peft import PeftModel
|
| 35 |
+
|
| 36 |
+
# Load base model and tokenizer
|
| 37 |
+
base_model = AutoModelForCausalLM.from_pretrained(
|
| 38 |
+
"meta-llama/Meta-Llama-3-8B-Instruct",
|
| 39 |
+
torch_dtype=torch.bfloat16,
|
| 40 |
+
device_map="auto"
|
| 41 |
+
)
|
| 42 |
+
tokenizer = AutoTokenizer.from_pretrained("meta-llama/Meta-Llama-3-8B-Instruct")
|
| 43 |
+
|
| 44 |
+
# Load and merge LoRA
|
| 45 |
+
model = PeftModel.from_pretrained(base_model, "YOUR_USERNAME/llama-traces")
|
| 46 |
+
model = model.merge_and_unload()
|
| 47 |
+
|
| 48 |
+
# Generate tool-calling responses
|
| 49 |
+
def generate_tool_call(prompt):
|
| 50 |
+
inputs = tokenizer(prompt, return_tensors="pt")
|
| 51 |
+
outputs = model.generate(
|
| 52 |
+
**inputs,
|
| 53 |
+
max_new_tokens=512,
|
| 54 |
+
temperature=0.7,
|
| 55 |
+
do_sample=True,
|
| 56 |
+
pad_token_id=tokenizer.eos_token_id
|
| 57 |
+
)
|
| 58 |
+
return tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 59 |
+
|
| 60 |
+
# Example usage
|
| 61 |
+
prompt = "Check the weather in New York"
|
| 62 |
+
response = generate_tool_call(prompt)
|
| 63 |
+
print(response)
|
| 64 |
+
```
|
| 65 |
+
|
| 66 |
+
### Expected Output Format
|
| 67 |
+
|
| 68 |
+
The model generates structured JSON responses like:
|
| 69 |
+
```json
|
| 70 |
+
{
|
| 71 |
+
"trace_id": "002",
|
| 72 |
+
"steps": [
|
| 73 |
+
{
|
| 74 |
+
"action": "call_api",
|
| 75 |
+
"api": "weather_api",
|
| 76 |
+
"arguments": {"location": "New York"}
|
| 77 |
+
},
|
| 78 |
+
{
|
| 79 |
+
"action": "respond",
|
| 80 |
+
"message": "The weather in New York is currently sunny with a temperature of 72°F."
|
| 81 |
+
}
|
| 82 |
+
]
|
| 83 |
+
}
|
| 84 |
+
```
|
| 85 |
+
|
| 86 |
+
## Training Details
|
| 87 |
+
|
| 88 |
+
- **Dataset**: Custom tool-calling dataset with instruction/input/output format
|
| 89 |
+
- **Template**: llama3 chat template
|
| 90 |
+
- **Cutoff Length**: 4096 tokens
|
| 91 |
+
- **Batch Size**: 2 (effective batch size: 8 with gradient accumulation)
|
| 92 |
+
- **Optimizer**: AdamW with cosine learning rate scheduling
|
| 93 |
+
- **Warmup Ratio**: 0.1
|
| 94 |
+
|
| 95 |
+
## Performance
|
| 96 |
+
|
| 97 |
+
The model shows improved capability in:
|
| 98 |
+
- Generating structured JSON responses
|
| 99 |
+
- Following tool-calling patterns
|
| 100 |
+
- Maintaining context for multi-step tool execution
|
| 101 |
+
- Producing consistent output formats
|
| 102 |
+
|
| 103 |
+
## Limitations
|
| 104 |
+
|
| 105 |
+
- Requires the base LLaMA-3-8B-Instruct model to function
|
| 106 |
+
- May generate invalid JSON in some edge cases
|
| 107 |
+
- Performance depends on the quality of the training data
|
| 108 |
+
|
| 109 |
+
## License
|
| 110 |
+
|
| 111 |
+
This model is released under the MIT License.
|