Update README.md
Browse files
README.md
CHANGED
|
@@ -1,202 +1,175 @@
|
|
| 1 |
---
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
---
|
| 5 |
|
| 6 |
-
#
|
| 7 |
|
| 8 |
-
|
| 9 |
|
|
|
|
| 10 |
|
|
|
|
| 11 |
|
| 12 |
-
|
| 13 |
|
| 14 |
-
|
| 15 |
|
| 16 |
-
|
| 17 |
|
|
|
|
| 18 |
|
|
|
|
| 19 |
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
- **Shared by [optional]:** [More Information Needed]
|
| 23 |
-
- **Model type:** [More Information Needed]
|
| 24 |
-
- **Language(s) (NLP):** [More Information Needed]
|
| 25 |
-
- **License:** [More Information Needed]
|
| 26 |
-
- **Finetuned from model [optional]:** [More Information Needed]
|
| 27 |
|
| 28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
|
| 30 |
-
|
| 31 |
|
| 32 |
-
|
| 33 |
-
- **Paper [optional]:** [More Information Needed]
|
| 34 |
-
- **Demo [optional]:** [More Information Needed]
|
| 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 |
|
| 66 |
-
|
|
|
|
|
|
|
| 67 |
|
| 68 |
-
|
| 69 |
|
| 70 |
-
|
| 71 |
|
| 72 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
|
| 74 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
|
| 76 |
-
|
| 77 |
|
| 78 |
-
|
|
|
|
|
|
|
| 79 |
|
| 80 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 81 |
|
| 82 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 83 |
|
| 84 |
-
### Training Procedure
|
| 85 |
-
|
| 86 |
-
<!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
|
| 87 |
-
|
| 88 |
-
#### Preprocessing [optional]
|
| 89 |
-
|
| 90 |
-
[More Information Needed]
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
#### Training Hyperparameters
|
| 94 |
-
|
| 95 |
-
- **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
|
| 96 |
-
|
| 97 |
-
#### Speeds, Sizes, Times [optional]
|
| 98 |
-
|
| 99 |
-
<!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
|
| 100 |
-
|
| 101 |
-
[More Information Needed]
|
| 102 |
-
|
| 103 |
-
## Evaluation
|
| 104 |
-
|
| 105 |
-
<!-- This section describes the evaluation protocols and provides the results. -->
|
| 106 |
-
|
| 107 |
-
### Testing Data, Factors & Metrics
|
| 108 |
-
|
| 109 |
-
#### Testing Data
|
| 110 |
-
|
| 111 |
-
<!-- This should link to a Dataset Card if possible. -->
|
| 112 |
-
|
| 113 |
-
[More Information Needed]
|
| 114 |
-
|
| 115 |
-
#### Factors
|
| 116 |
-
|
| 117 |
-
<!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
|
| 118 |
-
|
| 119 |
-
[More Information Needed]
|
| 120 |
-
|
| 121 |
-
#### Metrics
|
| 122 |
-
|
| 123 |
-
<!-- These are the evaluation metrics being used, ideally with a description of why. -->
|
| 124 |
-
|
| 125 |
-
[More Information Needed]
|
| 126 |
-
|
| 127 |
-
### Results
|
| 128 |
-
|
| 129 |
-
[More Information Needed]
|
| 130 |
-
|
| 131 |
-
#### Summary
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
## Model Examination [optional]
|
| 136 |
-
|
| 137 |
-
<!-- Relevant interpretability work for the model goes here -->
|
| 138 |
-
|
| 139 |
-
[More Information Needed]
|
| 140 |
-
|
| 141 |
-
## Environmental Impact
|
| 142 |
-
|
| 143 |
-
<!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
|
| 144 |
-
|
| 145 |
-
Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
|
| 146 |
-
|
| 147 |
-
- **Hardware Type:** [More Information Needed]
|
| 148 |
-
- **Hours used:** [More Information Needed]
|
| 149 |
-
- **Cloud Provider:** [More Information Needed]
|
| 150 |
-
- **Compute Region:** [More Information Needed]
|
| 151 |
-
- **Carbon Emitted:** [More Information Needed]
|
| 152 |
-
|
| 153 |
-
## Technical Specifications [optional]
|
| 154 |
-
|
| 155 |
-
### Model Architecture and Objective
|
| 156 |
-
|
| 157 |
-
[More Information Needed]
|
| 158 |
-
|
| 159 |
-
### Compute Infrastructure
|
| 160 |
-
|
| 161 |
-
[More Information Needed]
|
| 162 |
-
|
| 163 |
-
#### Hardware
|
| 164 |
-
|
| 165 |
-
[More Information Needed]
|
| 166 |
-
|
| 167 |
-
#### Software
|
| 168 |
-
|
| 169 |
-
[More Information Needed]
|
| 170 |
-
|
| 171 |
-
## Citation [optional]
|
| 172 |
-
|
| 173 |
-
<!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
|
| 174 |
-
|
| 175 |
-
**BibTeX:**
|
| 176 |
-
|
| 177 |
-
[More Information Needed]
|
| 178 |
-
|
| 179 |
-
**APA:**
|
| 180 |
-
|
| 181 |
-
[More Information Needed]
|
| 182 |
-
|
| 183 |
-
## Glossary [optional]
|
| 184 |
-
|
| 185 |
-
<!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
|
| 186 |
-
|
| 187 |
-
[More Information Needed]
|
| 188 |
-
|
| 189 |
-
## More Information [optional]
|
| 190 |
-
|
| 191 |
-
[More Information Needed]
|
| 192 |
-
|
| 193 |
-
## Model Card Authors [optional]
|
| 194 |
-
|
| 195 |
-
[More Information Needed]
|
| 196 |
-
|
| 197 |
-
## Model Card Contact
|
| 198 |
-
|
| 199 |
-
[More Information Needed]
|
| 200 |
-
### Framework versions
|
| 201 |
-
|
| 202 |
-
- PEFT 0.15.2
|
|
|
|
| 1 |
---
|
| 2 |
+
license: cc-by-4.0
|
| 3 |
+
language:
|
| 4 |
+
- bg
|
| 5 |
+
base_model:
|
| 6 |
+
- INSAIT-Institute/BgGPT-Gemma-2-2.6B-IT-v1.0
|
| 7 |
+
tags:
|
| 8 |
+
- function_calling
|
| 9 |
+
- MCP
|
| 10 |
+
- tool_use
|
| 11 |
---
|
| 12 |
|
| 13 |
+
# LLMBG-ToolUse: Bulgarian Language Models for Function Calling 🇧🇬
|
| 14 |
|
| 15 |
+
> 📄 **Full methodology, dataset details, and evaluation results coming in the upcoming paper**
|
| 16 |
|
| 17 |
+
## Overview 🚀
|
| 18 |
|
| 19 |
+
LLMBG-ToolUse is a series of open-source Bulgarian language models fine-tuned specifically for function calling and tool use.
|
| 20 |
|
| 21 |
+
These models can interact with external tools, APIs, and databases, making them appropriate for building AI agents and [Model Context Protocol (MCP)](https://arxiv.org/abs/2503.23278) applications.
|
| 22 |
|
| 23 |
+
Built on top of [BgGPT models](https://huggingface.co/collections/INSAIT-Institute/bggpt-gemma-2-673b972fe9902749ac90f6fe) from [INSAIT Institute](https://insait.ai/), these models have been enhanced with function-calling capabilities.
|
| 24 |
|
| 25 |
+
## Motivation 🎯
|
| 26 |
|
| 27 |
+
Although BgGPT models demonstrate [strong Bulgarian language comprehension](https://arxiv.org/pdf/2412.10893), they face challenges in maintaining the precise formatting necessary for consistent function calling. Despite implementing detailed system prompts, their performance in this specific task remains suboptimal.
|
| 28 |
|
| 29 |
+
This project addresses that gap by fine-tuning BgGPT, providing the Bulgarian AI community with proper tool-use capabilities in their native language.
|
| 30 |
|
| 31 |
+
## Models and variants 📦
|
| 32 |
+
Available in three sizes with full models, LoRA adapters, and quantized GGUF variants:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
|
| 34 |
+
| Model Size | Full Model | LoRA Adapter | GGUF (Quantized) |
|
| 35 |
+
|------------|------------|--------------|------------------|
|
| 36 |
+
| **2.6B** | [LLMBG-ToolUse-2.6B-v1.0](https://huggingface.co/s-emanuilov/LLMBG-ToolUse-2.6B-v1.0)| [LoRA](https://huggingface.co/s-emanuilov/LLMBG-ToolUse-2.6B-v1.0-LoRA) 📍| [GGUF](https://huggingface.co/s-emanuilov/LLMBG-ToolUse-2.6B-v1.0-GGUF) |
|
| 37 |
+
| **9B** | [LLMBG-ToolUse-9B-v1.0](https://huggingface.co/s-emanuilov/LLMBG-ToolUse-9B-v1.0) | [LoRA](https://huggingface.co/s-emanuilov/LLMBG-ToolUse-9B-v1.0-LoRA) | [GGUF](https://huggingface.co/s-emanuilov/LLMBG-ToolUse-9B-v1.0-GGUF) |
|
| 38 |
+
| **27B** | [LLMBG-ToolUse-27B-v1.0](https://huggingface.co/s-emanuilov/LLMBG-ToolUse-27B-v1.0) | [LoRA](https://huggingface.co/s-emanuilov/LLMBG-ToolUse-27B-v1.0-LoRA) | [GGUF](https://huggingface.co/s-emanuilov/LLMBG-ToolUse-27B-v1.0-GGUF) |
|
| 39 |
|
| 40 |
+
*GGUF variants include: q4_k_m, q5_k_m, q6_k, q8_0, q4_0 quantizations*
|
| 41 |
|
| 42 |
+
## Usage 🛠️
|
|
|
|
|
|
|
| 43 |
|
| 44 |
+
### Quick Start ⚡
|
| 45 |
+
```bash
|
| 46 |
+
pip install -U "transformers[torch]" accelerate bitsandbytes
|
| 47 |
+
```
|
| 48 |
|
| 49 |
+
### Prompt format ⚙️
|
| 50 |
+
**Critical:** Use this format for function calling for the best results.
|
| 51 |
|
| 52 |
+
<details>
|
| 53 |
+
<summary><strong>📋 Required System Prompt Template</strong></summary>
|
| 54 |
|
| 55 |
+
```
|
| 56 |
+
<bos><start_of_turn>user
|
| 57 |
+
Ти си полезен AI асистент, който предоставя полезни и точни отговори.
|
| 58 |
|
| 59 |
+
Имаш достъп и можеш да извикаш една или повече функции, за да помогнеш с потребителското запитване. Използвай ги, само ако е необходимо и подходящо.
|
| 60 |
|
| 61 |
+
Когато използваш функция, форматирай извикването ѝ в блок ```tool_call``` на отделен ред, a след това ще получиш резултат от изпълнението в блок ```toll_response```.
|
| 62 |
|
| 63 |
+
## Шаблон за извикване:
|
| 64 |
+
```tool_call
|
| 65 |
+
{"name": <function-name>, "arguments": <args-json-object>}```
|
| 66 |
|
| 67 |
+
## Налични функции:
|
| 68 |
+
[your function definitions here]
|
| 69 |
|
| 70 |
+
## Потребителска заявка :
|
| 71 |
+
[your query in Bulgarian]<end_of_turn>
|
| 72 |
+
<start_of_turn>model
|
| 73 |
+
```
|
| 74 |
|
| 75 |
+
</details>
|
| 76 |
|
| 77 |
+
### Note 📝
|
| 78 |
+
**The model only generates the `tool_call` blocks with function names and parameters - it doesn't actually execute the functions.** Your client application must parse these generated calls, execute the actual functions (API calls, database queries, etc.), and provide the results back to the model in `tool_response` blocks for the conversation to continue the interperation of the results. A full demo is comming soon.
|
| 79 |
|
| 80 |
+
### Python example 🐍
|
| 81 |
|
| 82 |
+
<details>
|
| 83 |
+
<summary><strong>💻 Complete Working Example</strong></summary>
|
| 84 |
|
| 85 |
+
```python
|
| 86 |
+
import torch
|
| 87 |
+
import json
|
| 88 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer, GenerationConfig
|
| 89 |
|
| 90 |
+
# Load model
|
| 91 |
+
model_name = "s-emanuilov/LLMBG-ToolUse-2.6B-v1.0"
|
| 92 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 93 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 94 |
+
model_name,
|
| 95 |
+
torch_dtype=torch.bfloat16,
|
| 96 |
+
device_map="auto",
|
| 97 |
+
attn_implementation="eager" # Required for Gemma models
|
| 98 |
+
)
|
| 99 |
|
| 100 |
+
# Create prompt with system template
|
| 101 |
+
def create_prompt(functions, user_query):
|
| 102 |
+
system_prompt = """Ти си полезен AI асистент, който предоставя полезни и точни отговори.
|
| 103 |
|
| 104 |
+
Имаш достъп и можеш да извикаш една или повече функции, за да помогнеш с потребителското запитване. Използвай ги, само ако е необходимо и подходящо.
|
| 105 |
|
| 106 |
+
Когато използваш функция, форматирай извикването ѝ в блок ```tool_call``` на отделен ред, a след това ще получиш резултат от изпълнението в блок ```toll_response```.
|
| 107 |
|
| 108 |
+
## Шаблон за извикване:
|
| 109 |
+
```tool_call
|
| 110 |
+
{{"name": <function-name>, "arguments": <args-json-object>}}```
|
| 111 |
+
"""
|
| 112 |
+
|
| 113 |
+
functions_text = json.dumps(functions, ensure_ascii=False, indent=2)
|
| 114 |
+
full_prompt = f"{system_prompt}\n## Налични функции:\n{functions_text}\n\n## Потребителска заявка:\n{user_query}"
|
| 115 |
+
|
| 116 |
+
chat = [{"role": "user", "content": full_prompt}]
|
| 117 |
+
return tokenizer.apply_chat_template(chat, tokenize=False, add_generation_prompt=True)
|
| 118 |
|
| 119 |
+
# Example usage
|
| 120 |
+
functions = [{
|
| 121 |
+
"name": "create_calendar_event",
|
| 122 |
+
"description": "Creates a new event in Google Calendar.",
|
| 123 |
+
"parameters": {
|
| 124 |
+
"type": "object",
|
| 125 |
+
"properties": {
|
| 126 |
+
"title": {"type": "string"},
|
| 127 |
+
"date": {"type": "string"},
|
| 128 |
+
"start_time": {"type": "string"},
|
| 129 |
+
"end_time": {"type": "string"}
|
| 130 |
+
},
|
| 131 |
+
"required": ["title", "date", "start_time", "end_time"]
|
| 132 |
+
}
|
| 133 |
+
}]
|
| 134 |
|
| 135 |
+
query = "Създай събитие 'Годишен преглед' за 8-ми юни 2025 от 14:00 до 14:30."
|
| 136 |
|
| 137 |
+
# Generate response
|
| 138 |
+
prompt = create_prompt(functions, query)
|
| 139 |
+
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
|
| 140 |
|
| 141 |
+
outputs = model.generate(
|
| 142 |
+
**inputs,
|
| 143 |
+
max_new_tokens=1024,
|
| 144 |
+
temperature=0.1,
|
| 145 |
+
top_k=25,
|
| 146 |
+
top_p=1.0,
|
| 147 |
+
repetition_penalty=1.1,
|
| 148 |
+
do_sample=True,
|
| 149 |
+
eos_token_id=[tokenizer.eos_token_id, tokenizer.convert_tokens_to_ids("<end_of_turn>")],
|
| 150 |
+
pad_token_id=tokenizer.eos_token_id
|
| 151 |
+
)
|
| 152 |
+
|
| 153 |
+
result = tokenizer.decode(outputs[0][inputs.input_ids.shape[1]:], skip_special_tokens=True)
|
| 154 |
+
print(result)
|
| 155 |
+
```
|
| 156 |
+
|
| 157 |
+
</details>
|
| 158 |
|
| 159 |
+
## Performance & Dataset 📊
|
| 160 |
+
|
| 161 |
+
> 📄 **Full methodology, dataset details, and comprehensive evaluation results coming in the upcoming paper**
|
| 162 |
+
|
| 163 |
+
**Dataset:** 2,000+ bilingual (Bulgarian/English) function-calling examples from manual curation + synthetic generation (Gemini/GPT-4).
|
| 164 |
+
|
| 165 |
+
**Results:** ~40% improvement in tool-use capabilities over base BgGPT models in internal benchmarks.
|
| 166 |
+
|
| 167 |
+
## Questions & Contact 💬
|
| 168 |
+
For questions, collaboration, or feedback: **[Connect on LinkedIn](https://www.linkedin.com/in/simeon-emanuilov/)**
|
| 169 |
+
|
| 170 |
+
## Acknowledgments 🙏
|
| 171 |
+
Built on top of [BgGPT series](https://huggingface.co/collections/INSAIT-Institute/bggpt-gemma-2-673b972fe9902749ac90f6fe).
|
| 172 |
+
|
| 173 |
+
## License 📄
|
| 174 |
+
This work is licensed under [CC-BY-4.0](https://creativecommons.org/licenses/by/4.0/).
|
| 175 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|