yashsoni78 commited on
Commit
db8af70
Β·
verified Β·
1 Parent(s): e93b9ee

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +49 -70
README.md CHANGED
@@ -1,98 +1,77 @@
1
  ---
2
- license: apache-2.0
3
- datasets:
4
- - yashsoni78/conversation_data_mcp_100
5
- language:
6
- - en
7
- base_model:
8
- - mistralai/Mistral-7B-Instruct-v0.2
9
- library_name: adapter-transformers
10
  tags:
11
- - code
12
- ---
13
- # MCP Tool-Calling (v1)
14
-
15
- This repository contains a specialized version of `mistralai/Mistral-7B-Instruct-v0.2`, fine-tuned to function as a reasoning engine for a tool-calling AI agent.
16
-
17
- The model has been trained to understand natural language requests related to a custom set of "MCP" tools and translate them into a specific, structured format suitable for execution in an application backend.
18
-
 
 
 
19
  ---
20
- ## Model Description
21
-
22
- This model was fine-tuned using **Parameter-Efficient Fine-Tuning (PEFT)** with **LoRA** on a custom, high-quality dataset. Its primary skill is to receive a user prompt and generate a tool call in a specific, sandboxed format. While the fine-tuning has exposed it to several tool types, its core capability is understanding the intent to use a tool and structuring the output accordingly.
23
 
24
- The model expects prompts in a `SYSTEM-USER-ASSISTANT` format and has been trained to generate tool calls with the 'tool_code' format..
25
 
26
- ## Intended Use
27
 
28
- This model is not a general-purpose chatbot. It is a specialized component intended to be used within a larger application or "agent" that can parse and execute the generated code.
29
 
30
- * **Primary Use:** Translating natural language commands into structured code for automation.
31
- * **Out of Scope:** General conversation, creative writing, or tasks outside its trained toolset.
 
 
32
 
33
- ---
34
- ## How to Use
35
 
36
- The model is a PEFT adapter, meaning you must load it on top of the original base model. The following code provides a complete example of how to load the model from the Hub and run inference.
37
 
38
  ```python
39
- import torch
40
  from transformers import AutoModelForCausalLM, AutoTokenizer
41
- from peft import PeftModel
 
 
42
 
43
- # --- 1. Configuration ---
44
- BASE_MODEL_REPO_ID = "mistralai/Mistral-7B-Instruct-v0.2"
45
- # Replace with your actual model repository ID on the Hub
46
- FINE_TUNED_REPO_ID = "yashsoni78/mcp_tool_model"
47
- DEVICE = "cuda" if torch.cuda.is_available() else "cpu"
48
 
49
- # --- 2. Load Model and Tokenizer ---
50
- print(f"Loading base model: {BASE_MODEL_REPO_ID}")
51
- base_model = AutoModelForCausalLM.from_pretrained(
52
- BASE_MODEL_REPO_ID,
53
- torch_dtype=torch.bfloat16,
54
- device_map=DEVICE
55
- )
56
 
57
- print(f"Loading fine-tuned adapter & tokenizer from: {FINE_TUNED_REPO_ID}")
58
- tokenizer = AutoTokenizer.from_pretrained(FINE_TUNED_REPO_ID)
59
 
60
- # Resize token embeddings to account for any special tokens added during training
61
- base_model.resize_token_embeddings(len(tokenizer))
62
 
63
- # Load the LoRA adapter and merge it into the base model for faster inference
64
- model = PeftModel.from_pretrained(base_model, FINE_TUNED_REPO_ID)
65
- model = model.merge_and_unload()
66
- model.eval() # Set the model to evaluation mode
67
 
68
- print("βœ… Model loaded successfully.")
69
 
70
- # --- 3. Run Inference ---
71
- system_prompt = "You are an expert assistant that uses MCP tools. When a tool is required, you must respond *only* with the 'tool_code' format."
72
- user_prompt = "What's the status of my 'database-main' VM?"
73
 
74
- formatted_prompt = f"SYSTEM: {system_prompt}\nUSER: {user_prompt}\nASSISTANT:"
75
- inputs = tokenizer(formatted_prompt, return_tensors="pt").to(DEVICE)
 
 
76
 
77
- outputs = model.generate(**inputs, max_new_tokens=150, pad_token_id=tokenizer.eos_token_id)
78
- response = tokenizer.decode(outputs[0], skip_special_tokens=True).split("ASSISTANT:")[1].strip()
79
 
80
- print("\n--- Model Output ---")
81
- print(response)
 
82
 
83
- ````
84
 
85
- ## Training Details
86
 
87
- * **Base Model:** `mistralai/Mistral-7B-Instruct-v0.2`
88
- * **Fine-Tuning Method:** PEFT (LoRA) with 4-bit quantization (`bitsandbytes`).
89
- * **Dataset:** The model was trained on a curated, high-quality dataset containing a balanced mix of tool-calling examples and conversational ("negative") examples to teach it when *not* to call a tool. Special tokens `[TOOL_CODE_START]` and `[TOOL_CODE_END]` were added to the vocabulary.
90
- * **Training Procedure:** The model was trained using the `SFTTrainer` from the TRL library.
91
 
92
- ## Limitations and Bias
93
 
94
- * **Syntax Hallucination:** As a probabilistic model, it may occasionally generate tool calls with slightly incorrect syntax (e.g., wrong object names, extra parameters). It is **highly recommended** to use this model within an application that performs a `Parse -> Validate -> Execute` loop to ensure safety and reliability.
95
- * **Scope:** The model's knowledge is limited to the patterns and tools seen during fine-tuning. It cannot use new tools without being re-trained.
96
- * **Language:** The model was trained exclusively on English language prompts.
97
 
98
- ```
 
1
  ---
2
+ license: mit
 
 
 
 
 
 
 
3
  tags:
4
+ - conversational
5
+ - text-generation
6
+ - instruction-tuned
7
+ - chat
8
+ - dialogue
9
+ language:
10
+ - en
11
+ datasets:
12
+ - yashsoni78/conversation_data_mcp_100
13
+ library_name: transformers
14
+ pipeline_tag: text-generation
15
  ---
 
 
 
16
 
17
+ # πŸ› οΈ MCP Tool Model
18
 
19
+ The **MCP Tool Model** is an instruction-tuned conversational language model fine-tuned on the [`conversation_data_mcp_100`](https://huggingface.co/datasets/yashsoni78/conversation_data_mcp_100) dataset. Built to handle multi-turn dialogues with clarity and coherence, this model is ideal for chatbot development, virtual assistants, or any conversational AI tasks.
20
 
21
+ ## 🧠 Model Details
22
 
23
+ - **Base Model**: *mistralai/Mistral-7B-Instruct-v0.2*
24
+ - **Fine-tuned on**: Custom multi-turn conversation dataset (`yashsoni78/conversation_data_mcp_100`)
25
+ - **Languages**: English
26
+ - **Use case**: General-purpose chatbot or instruction-following agent
27
 
28
+ ## πŸš€ Example Usage
 
29
 
30
+ You can load and use the model with the Hugging Face Transformers library:
31
 
32
  ```python
 
33
  from transformers import AutoModelForCausalLM, AutoTokenizer
34
+ import torch
35
+
36
+ model_name = "yashsoni78/mcp_tool_model"
37
 
38
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
39
+ model = AutoModelForCausalLM.from_pretrained(model_name)
 
 
 
40
 
41
+ input_text = "User: How do I reset my password?\nAssistant:"
42
+ inputs = tokenizer(input_text, return_tensors="pt")
43
+ outputs = model.generate(**inputs, max_new_tokens=100)
 
 
 
 
44
 
45
+ print(tokenizer.decode(outputs[0], skip_special_tokens=True))
46
+ ```
47
 
48
+ > πŸ’‘ Make sure to adapt the prompt formatting depending on your training setup (e.g., special tokens, roles, etc.)
 
49
 
50
+ ## πŸ“š Training Data
 
 
 
51
 
52
+ This model was fine-tuned on the [MCP 100 conversation dataset](https://huggingface.co/datasets/yashsoni78/conversation_data_mcp_100), consisting of 100 high-quality multi-turn dialogues between users and assistants. Each exchange is structured to reflect real-world inquiry-response flows.
53
 
54
+ ## πŸ“Š Intended Use
 
 
55
 
56
+ - Chatbots for websites or tools
57
+ - Instruction-following agents
58
+ - Dialogue research
59
+ - Voice assistant backend
60
 
61
+ ## ⚠️ Limitations
 
62
 
63
+ - May hallucinate facts or generate inaccurate responses.
64
+ - Trained on a small dataset (100 dialogues), so generalization may be limited.
65
+ - English only.
66
 
67
+ ## πŸ“œ License
68
 
69
+ This model is licensed under the [MIT License](https://opensource.org/licenses/MIT). You are free to use, modify, and distribute it with attribution.
70
 
71
+ ## πŸ™ Acknowledgements
 
 
 
72
 
73
+ Special thanks to the open-source community and Hugging Face for providing powerful tools to build and share models easily.
74
 
75
+ ## πŸ“¬ Contact
 
 
76
 
77
+ For issues, feedback, or collaborations, feel free to reach out to [@yashsoni78](https://huggingface.co/yashsoni78).