Update README.md
Browse files
README.md
CHANGED
|
@@ -2,4 +2,71 @@
|
|
| 2 |
license: cc-by-sa-4.0
|
| 3 |
datasets:
|
| 4 |
- glaiveai/glaive-function-calling
|
| 5 |
-
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
license: cc-by-sa-4.0
|
| 3 |
datasets:
|
| 4 |
- glaiveai/glaive-function-calling
|
| 5 |
+
---
|
| 6 |
+
# glaive-function-calling-v1
|
| 7 |
+
|
| 8 |
+
glaive-function-calling-v1 is a 2.7B parameter open source chat model trained on data generated from Glaive’s synthetic data generation platform, which has similar function calling abilities as gpt-3.5 and gpt 4.
|
| 9 |
+
|
| 10 |
+
The model is capable of having multi-turn conversations and intelligently choosing when to execute a function (provided at the beginning of the conversation as a system prompt) based on the conversation. The model is trained on top of the (replit-code-v1-3b)[https://huggingface.co/replit/replit-code-v1-3b] model.
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
## Usage:
|
| 14 |
+
|
| 15 |
+
You can run the model in the following way-
|
| 16 |
+
```
|
| 17 |
+
from transformers import AutoModelForCausalLM , AutoTokenizer
|
| 18 |
+
|
| 19 |
+
tokenizer = AutoTokenizer.from_pretrained("glaiveai/glaive-function-calling-v1", trust_remote_code=True)
|
| 20 |
+
model = AutoModelForCausalLM.from_pretrained("glaiveai/glaive-function-calling-v1", trust_remote_code=True).half().cuda()
|
| 21 |
+
|
| 22 |
+
inputs = tokenizer(prompt,return_tensors="pt").to(model.device)
|
| 23 |
+
|
| 24 |
+
outputs = model.generate(**inputs,do_sample=True,temperature=0.1,top_p=0.95,max_new_tokens=100)
|
| 25 |
+
|
| 26 |
+
print(tokenizer.decode(outputs[0],skip_special_tokens=True))
|
| 27 |
+
```
|
| 28 |
+
|
| 29 |
+
This model uses the following prompt format-
|
| 30 |
+
|
| 31 |
+
```
|
| 32 |
+
SYSTEM: You are an helpful assistant who has access to the following functions to help the user, you can use the functions if needed-
|
| 33 |
+
{
|
| 34 |
+
"name": "plan_holiday",
|
| 35 |
+
"description": "Plan a holiday based on user's interests",
|
| 36 |
+
"parameters": {
|
| 37 |
+
"type": "object",
|
| 38 |
+
"properties": {
|
| 39 |
+
"destination": {
|
| 40 |
+
"type": "string",
|
| 41 |
+
"description": "The destination of the holiday",
|
| 42 |
+
},
|
| 43 |
+
"duration": {
|
| 44 |
+
"type": "integer",
|
| 45 |
+
"description": "The duration of the trip in holiday",
|
| 46 |
+
},
|
| 47 |
+
},
|
| 48 |
+
"required": ["destination", "duration"],
|
| 49 |
+
},
|
| 50 |
+
}
|
| 51 |
+
USER: I am thinking of having a 10 day long vacation in Greece, can you help me plan it?
|
| 52 |
+
```
|
| 53 |
+
Based on which the model outputs-
|
| 54 |
+
```
|
| 55 |
+
ASSISTANT: <functioncall> {"name": "plan_holiday", "arguments": '{
|
| 56 |
+
"destination": "Greece",
|
| 57 |
+
"duration": 10
|
| 58 |
+
}'}
|
| 59 |
+
```
|
| 60 |
+
The model precedes all function invocations with `<functioncall>`.
|
| 61 |
+
|
| 62 |
+
The response of the function call should be sent to the model as-
|
| 63 |
+
|
| 64 |
+
```
|
| 65 |
+
FUNCTION CALL: {"places_to_visit":["Athens","Santorini","Mykonos"]}
|
| 66 |
+
```
|
| 67 |
+
|
| 68 |
+
The model can do multi-turn conversation in the above format.
|
| 69 |
+
|
| 70 |
+
|
| 71 |
+
We're working on providing an inference server which can act as a drop in replacement to the OpenAI API, you can follow (this)[https://github.com/glaive-ai/function-calling-server] repo for the server.
|
| 72 |
+
|