初始化项目,由ModelHub XC社区提供模型
Model: QuantFactory/Meta-Llama-3-8B-Instruct-function-calling-json-mode-GGUF Source: Original Platform
This commit is contained in:
49
.gitattributes
vendored
Normal file
49
.gitattributes
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
*.7z filter=lfs diff=lfs merge=lfs -text
|
||||
*.arrow filter=lfs diff=lfs merge=lfs -text
|
||||
*.bin filter=lfs diff=lfs merge=lfs -text
|
||||
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
||||
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
||||
*.ftz filter=lfs diff=lfs merge=lfs -text
|
||||
*.gz filter=lfs diff=lfs merge=lfs -text
|
||||
*.h5 filter=lfs diff=lfs merge=lfs -text
|
||||
*.joblib filter=lfs diff=lfs merge=lfs -text
|
||||
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
||||
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
||||
*.model filter=lfs diff=lfs merge=lfs -text
|
||||
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
||||
*.npy filter=lfs diff=lfs merge=lfs -text
|
||||
*.npz filter=lfs diff=lfs merge=lfs -text
|
||||
*.onnx filter=lfs diff=lfs merge=lfs -text
|
||||
*.ot filter=lfs diff=lfs merge=lfs -text
|
||||
*.parquet filter=lfs diff=lfs merge=lfs -text
|
||||
*.pb filter=lfs diff=lfs merge=lfs -text
|
||||
*.pickle filter=lfs diff=lfs merge=lfs -text
|
||||
*.pkl filter=lfs diff=lfs merge=lfs -text
|
||||
*.pt filter=lfs diff=lfs merge=lfs -text
|
||||
*.pth filter=lfs diff=lfs merge=lfs -text
|
||||
*.rar filter=lfs diff=lfs merge=lfs -text
|
||||
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
||||
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
||||
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
||||
*.tar filter=lfs diff=lfs merge=lfs -text
|
||||
*.tflite filter=lfs diff=lfs merge=lfs -text
|
||||
*.tgz filter=lfs diff=lfs merge=lfs -text
|
||||
*.wasm filter=lfs diff=lfs merge=lfs -text
|
||||
*.xz filter=lfs diff=lfs merge=lfs -text
|
||||
*.zip filter=lfs diff=lfs merge=lfs -text
|
||||
*.zst filter=lfs diff=lfs merge=lfs -text
|
||||
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
||||
Meta-Llama-3-8B-Instruct-function-calling-json-mode.Q2_K.gguf filter=lfs diff=lfs merge=lfs -text
|
||||
Meta-Llama-3-8B-Instruct-function-calling-json-mode.Q4_K_S.gguf filter=lfs diff=lfs merge=lfs -text
|
||||
Meta-Llama-3-8B-Instruct-function-calling-json-mode.Q4_K_M.gguf filter=lfs diff=lfs merge=lfs -text
|
||||
Meta-Llama-3-8B-Instruct-function-calling-json-mode.Q3_K_L.gguf filter=lfs diff=lfs merge=lfs -text
|
||||
Meta-Llama-3-8B-Instruct-function-calling-json-mode.Q3_K_M.gguf filter=lfs diff=lfs merge=lfs -text
|
||||
Meta-Llama-3-8B-Instruct-function-calling-json-mode.Q3_K_S.gguf filter=lfs diff=lfs merge=lfs -text
|
||||
Meta-Llama-3-8B-Instruct-function-calling-json-mode.Q8_0.gguf filter=lfs diff=lfs merge=lfs -text
|
||||
Meta-Llama-3-8B-Instruct-function-calling-json-mode.Q6_K.gguf filter=lfs diff=lfs merge=lfs -text
|
||||
Meta-Llama-3-8B-Instruct-function-calling-json-mode.Q5_K_M.gguf filter=lfs diff=lfs merge=lfs -text
|
||||
Meta-Llama-3-8B-Instruct-function-calling-json-mode.Q5_K_S.gguf filter=lfs diff=lfs merge=lfs -text
|
||||
Meta-Llama-3-8B-Instruct-function-calling-json-mode.Q5_0.gguf filter=lfs diff=lfs merge=lfs -text
|
||||
Meta-Llama-3-8B-Instruct-function-calling-json-mode.Q5_1.gguf filter=lfs diff=lfs merge=lfs -text
|
||||
Meta-Llama-3-8B-Instruct-function-calling-json-mode.Q4_1.gguf filter=lfs diff=lfs merge=lfs -text
|
||||
Meta-Llama-3-8B-Instruct-function-calling-json-mode.Q4_0.gguf filter=lfs diff=lfs merge=lfs -text
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:e281023b24f130599fef228b96cf00701768655e68dbb0893eb642cd3bef3359
|
||||
size 3179131136
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:ab2bc55ae5666925bad1767f2b6bd01b901872d7ff9ba071e544c0dc05cf4ca7
|
||||
size 4321956096
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:997536f7bc8800348fbdd059dc0115dc303fe34ca5957537fd13c24fe1314086
|
||||
size 4018917632
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:0e0ae6bd847afb7fc72230425bae31f5f37924a381be5e4ffe599b9ebabff555
|
||||
size 3664498944
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:e82101a5e60419e23519aa2f42542b9c64074048085ccc33487c2c6c3356994e
|
||||
size 4661211392
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:9e4ec0990b44779fec29060c6ade65b038e3a176f86fbb70f998932c22eab9fc
|
||||
size 5130252544
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:14a1dc9f01bbcfa56fdb271f8a8af65b4dc93fbf7bc387b98d2fc64c368f3f42
|
||||
size 4920733952
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:2c600482b5d0abecba870e51ed9e65c5e3e0c9c17d1c4390274487200603858a
|
||||
size 4692668672
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:9efd0a600b6273c9feebd8c709639baa11691940ea174447e17d26d72b9c59cb
|
||||
size 5599293696
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:702ee1bd8ca7cb930bedc0ed283b69ccafdf272fad3cf2f0e6161184a0d1bd19
|
||||
size 6068334848
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:f99eab0fa74ceb78f52820310d3caa3fd481851576f6a2b283bf2a124a4f6ac7
|
||||
size 5732987136
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:51a2166551b4d733aa309615c7aa12420463b396478fed60fdc12a60c3631bcc
|
||||
size 5599293696
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:ed72a1aad4c6898024ac0191d27d9766afd71d496c513299ef8af21a640512cc
|
||||
size 6596006144
|
||||
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:e81cc54c5c73bd6cc5b3f9e6889bf69d61ed68b2fc85eb251695af15da7f09df
|
||||
size 8540770560
|
||||
163
README.md
Normal file
163
README.md
Normal file
@@ -0,0 +1,163 @@
|
||||
---
|
||||
library_name: transformers
|
||||
tags:
|
||||
- text-generation-inference
|
||||
- transformers
|
||||
- unsloth
|
||||
- trl
|
||||
- llama
|
||||
language:
|
||||
- en
|
||||
base_model: hiieu/Meta-Llama-3-8B-Instruct-function-calling-json-mode
|
||||
pipeline_tag: text-generation
|
||||
---
|
||||
|
||||
# QuantFactory/Meta-Llama-3-8B-Instruct-function-calling-json-mode-GGUF
|
||||
This is quantized version of [hiieu/Meta-Llama-3-8B-Instruct-function-calling-json-mode](https://huggingface.co/hiieu/Meta-Llama-3-8B-Instruct-function-calling-json-mode) created using llama.cpp
|
||||
|
||||
## Model Description
|
||||
|
||||
This model was fine-tuned on meta-llama/Meta-Llama-3-8B-Instruct for function calling and json mode.
|
||||
|
||||
## Usage
|
||||
### JSON Mode
|
||||
```python
|
||||
from transformers import AutoTokenizer, AutoModelForCausalLM
|
||||
import torch
|
||||
|
||||
model_id = "hiieu/Meta-Llama-3-8B-Instruct-function-calling-json-mode"
|
||||
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
||||
model = AutoModelForCausalLM.from_pretrained(
|
||||
model_id,
|
||||
torch_dtype=torch.bfloat16,
|
||||
device_map="auto",
|
||||
)
|
||||
|
||||
messages = [
|
||||
{"role": "system", "content": "You are a helpful assistant, answer in JSON with key \"message\""},
|
||||
{"role": "user", "content": "Who are you?"},
|
||||
]
|
||||
|
||||
input_ids = tokenizer.apply_chat_template(
|
||||
messages,
|
||||
add_generation_prompt=True,
|
||||
return_tensors="pt"
|
||||
).to(model.device)
|
||||
|
||||
terminators = [
|
||||
tokenizer.eos_token_id,
|
||||
tokenizer.convert_tokens_to_ids("<|eot_id|>")
|
||||
]
|
||||
|
||||
outputs = model.generate(
|
||||
input_ids,
|
||||
max_new_tokens=256,
|
||||
eos_token_id=terminators,
|
||||
do_sample=True,
|
||||
temperature=0.6,
|
||||
top_p=0.9,
|
||||
)
|
||||
response = outputs[0][input_ids.shape[-1]:]
|
||||
print(tokenizer.decode(response, skip_special_tokens=True))
|
||||
# >> {"message": "I am a helpful assistant, with access to a vast amount of information. I can help you with tasks such as answering questions, providing definitions, translating text, and more. Feel free to ask me anything!"}
|
||||
```
|
||||
|
||||
### Function Calling
|
||||
Function calling requires two step inferences, below is the example:
|
||||
|
||||
## Step 1:
|
||||
|
||||
```python
|
||||
functions_metadata = [
|
||||
{
|
||||
"type": "function",
|
||||
"function": {
|
||||
"name": "get_temperature",
|
||||
"description": "get temperature of a city",
|
||||
"parameters": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"city": {
|
||||
"type": "string",
|
||||
"description": "name"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"city"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
messages = [
|
||||
{ "role": "system", "content": f"""You are a helpful assistant with access to the following functions: \n {str(functions_metadata)}\n\nTo use these functions respond with:\n<functioncall> {{ "name": "function_name", "arguments": {{ "arg_1": "value_1", "arg_1": "value_1", ... }} }} </functioncall>\n\nEdge cases you must handle:\n - If there are no functions that match the user request, you will respond politely that you cannot help."""},
|
||||
{ "role": "user", "content": "What is the temperature in Tokyo right now?"}
|
||||
]
|
||||
|
||||
input_ids = tokenizer.apply_chat_template(
|
||||
messages,
|
||||
add_generation_prompt=True,
|
||||
return_tensors="pt"
|
||||
).to(model.device)
|
||||
|
||||
terminators = [
|
||||
tokenizer.eos_token_id,
|
||||
tokenizer.convert_tokens_to_ids("<|eot_id|>")
|
||||
]
|
||||
|
||||
outputs = model.generate(
|
||||
input_ids,
|
||||
max_new_tokens=256,
|
||||
eos_token_id=terminators,
|
||||
do_sample=True,
|
||||
temperature=0.6,
|
||||
top_p=0.9,
|
||||
)
|
||||
response = outputs[0][input_ids.shape[-1]:]
|
||||
print(tokenizer.decode(response, skip_special_tokens=True))
|
||||
# >> <functioncall> {"name": "get_temperature", "arguments": '{"city": "Tokyo"}'} </functioncall>"""}
|
||||
```
|
||||
## Step 2:
|
||||
|
||||
```python
|
||||
messages = [
|
||||
{ "role": "system", "content": f"""You are a helpful assistant with access to the following functions: \n {str(functions_metadata)}\n\nTo use these functions respond with:\n<functioncall> {{ "name": "function_name", "arguments": {{ "arg_1": "value_1", "arg_1": "value_1", ... }} }} </functioncall>\n\nEdge cases you must handle:\n - If there are no functions that match the user request, you will respond politely that you cannot help."""},
|
||||
{ "role": "user", "content": "What is the temperature in Tokyo right now?"},
|
||||
# You will get the previous prediction, extract it will the tag <functioncall>
|
||||
# execute the function and append it to the messages like below:
|
||||
{ "role": "assistant", "content": """<functioncall> {"name": "get_temperature", "arguments": '{"city": "Tokyo"}'} </functioncall>"""},
|
||||
{ "role": "user", "content": """<function_response> {"temperature":30 C} </function_response>"""}
|
||||
]
|
||||
|
||||
input_ids = tokenizer.apply_chat_template(
|
||||
messages,
|
||||
add_generation_prompt=True,
|
||||
return_tensors="pt"
|
||||
).to(model.device)
|
||||
|
||||
terminators = [
|
||||
tokenizer.eos_token_id,
|
||||
tokenizer.convert_tokens_to_ids("<|eot_id|>")
|
||||
]
|
||||
|
||||
outputs = model.generate(
|
||||
input_ids,
|
||||
max_new_tokens=256,
|
||||
eos_token_id=terminators,
|
||||
do_sample=True,
|
||||
temperature=0.6,
|
||||
top_p=0.9,
|
||||
)
|
||||
response = outputs[0][input_ids.shape[-1]:]
|
||||
print(tokenizer.decode(response, skip_special_tokens=True))
|
||||
# >> The current temperature in Tokyo is 30 degrees Celsius.
|
||||
```
|
||||
|
||||
# Uploaded model
|
||||
|
||||
- **Developed by:** hiieu
|
||||
|
||||
This model was trained 2x faster with [Unsloth](https://github.com/unslothai/unsloth) and Huggingface's TRL library.
|
||||
|
||||
[<img src="https://raw.githubusercontent.com/unslothai/unsloth/main/images/unsloth%20made%20with%20love.png" width="200"/>](https://github.com/unslothai/unsloth)
|
||||
1
configuration.json
Normal file
1
configuration.json
Normal file
@@ -0,0 +1 @@
|
||||
{"framework": "pytorch", "task": "text-generation", "allow_remote": true}
|
||||
Reference in New Issue
Block a user