Instructions to use ghost-x/ghost-7b-alpha-gguf with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ghost-x/ghost-7b-alpha-gguf with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="ghost-x/ghost-7b-alpha-gguf") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("ghost-x/ghost-7b-alpha-gguf", dtype="auto") - llama-cpp-python
How to use ghost-x/ghost-7b-alpha-gguf with llama-cpp-python:
# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="ghost-x/ghost-7b-alpha-gguf", filename="ghost-7b-alpha-Q4_0.gguf", )
llm.create_chat_completion( messages = [ { "role": "user", "content": "What is the capital of France?" } ] ) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use ghost-x/ghost-7b-alpha-gguf with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf ghost-x/ghost-7b-alpha-gguf:Q4_K_M # Run inference directly in the terminal: llama cli -hf ghost-x/ghost-7b-alpha-gguf:Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf ghost-x/ghost-7b-alpha-gguf:Q4_K_M # Run inference directly in the terminal: llama cli -hf ghost-x/ghost-7b-alpha-gguf:Q4_K_M
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf ghost-x/ghost-7b-alpha-gguf:Q4_K_M # Run inference directly in the terminal: ./llama-cli -hf ghost-x/ghost-7b-alpha-gguf:Q4_K_M
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf ghost-x/ghost-7b-alpha-gguf:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama-cli -hf ghost-x/ghost-7b-alpha-gguf:Q4_K_M
Use Docker
docker model run hf.co/ghost-x/ghost-7b-alpha-gguf:Q4_K_M
- LM Studio
- Jan
- vLLM
How to use ghost-x/ghost-7b-alpha-gguf with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "ghost-x/ghost-7b-alpha-gguf" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ghost-x/ghost-7b-alpha-gguf", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/ghost-x/ghost-7b-alpha-gguf:Q4_K_M
- SGLang
How to use ghost-x/ghost-7b-alpha-gguf with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "ghost-x/ghost-7b-alpha-gguf" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ghost-x/ghost-7b-alpha-gguf", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "ghost-x/ghost-7b-alpha-gguf" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ghost-x/ghost-7b-alpha-gguf", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Ollama
How to use ghost-x/ghost-7b-alpha-gguf with Ollama:
ollama run hf.co/ghost-x/ghost-7b-alpha-gguf:Q4_K_M
- Unsloth Studio
How to use ghost-x/ghost-7b-alpha-gguf with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for ghost-x/ghost-7b-alpha-gguf to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for ghost-x/ghost-7b-alpha-gguf to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for ghost-x/ghost-7b-alpha-gguf to start chatting
- Atomic Chat new
- Docker Model Runner
How to use ghost-x/ghost-7b-alpha-gguf with Docker Model Runner:
docker model run hf.co/ghost-x/ghost-7b-alpha-gguf:Q4_K_M
- Lemonade
How to use ghost-x/ghost-7b-alpha-gguf with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull ghost-x/ghost-7b-alpha-gguf:Q4_K_M
Run and chat with the model
lemonade run user.ghost-7b-alpha-gguf-Q4_K_M
List all available models
lemonade list
Tool calls did not work as well as demo
Hi, I deployed your model using the Q4_K_M version and tested it with an elementary function. Here is the prompt that I used
plugins = [
{
"type": "function",
"function": {
"name": "add_two_number",
"description": "add two number x and y",
"parameters": {
"type": "object",
"properties": {
"x": {
"type": "number",
"description": "first number",
"required": True
},
"y": {
"type": "number",
"description": "second number",
"required": True
}
}
}
}
}
]
conversation = [
{"role": "system", "content": "Bạn là một trợ lí AI hữu ích. Hãy giúp đỡ người dùng càng chính xác càng tốt"},
{"role": "plugins", "content": json.dumps(plugins, ensure_ascii=False)},
{"role": "user", "content": "Hãy tính cho công thức sau 2 + 3"}
]
prompt = tokenizer.apply_chat_template(conversation, tokenize=False, add_generation_prompt=False)
payload = json.dumps({
"prompt": prompt,
"n_predict": 1024,
"temperature": 0.0,
"top_k": 40,
"min_p": 0.05,
"top_p": 0.9,
"stop": [],
"n_ctx": 4096,
"seed": 42,
"repeat_penalty": 1.1
})
headers = {
'Content-Type': 'application/json'
}
# I used llama.cpp server
response = requests.request("POST", url, headers=headers, data=payload)
content = response.json()["content"]
print(prompt + content)
Here is the result
<|system|>
Bạn là một trợ lí AI hữu ích. Hãy giúp đỡ người dùng càng chính xác càng tốt</s>
<|plugins|>
[{"type": "function", "function": {"name": "add_two_number", "description": "add two number x and y", "parameters": {"type": "object", "properties": {"x": {"type": "number", "description": "first number", "required": true}, "y": {"type": "number", "description": "second number", "required": true}}}}}]
Standards for using the tool must comply with the following syntax:
[execute]({"type": string, "function": string, "arguments": object})</s>
<|user|>
Hãy tính cho công thức sau 2 + 3</s>
<|assistant|>
[{"type": "func", "func": "add_two_number", "arguments": {"x": 2, "y": 3}}]
Kết quả: 5
Giải thích:
Hàm add_two_number(x, y) tính tổng của hai số x và y.
Trong trường hợp này, x = 2 và y = 3.
Do đó, kết quả là 5.</s>
I couldn't see the [execute] token/words that you showed in the demo
The reason may be that the compression in version Q4_K_M has affected the quality of the model.
Below I tried the same thing as you said above with the 4bit quantization via transformers.
I changed more parameters to try and convert numbers into Vietnamese words.
Add one more field, which will return the python code for calculation.
Hope you can try out other versions in the guff distribution and leave a comment here for everyone to refer to and discuss further about them.
@lamhieu Oh, I just realized that I downloaded the wrong gguf model. It should be the alpha version not, v0.9.1. My mistake!
The output is correct, just a small mistake in the word function in the key type
In addition, If I provide the execute and response messages, the model cannot generate the <|assistant|> token unless I set add_generation_prompt=True in token.apply_chat_template
Here is the output:
# add_generation_prompt=False
<|system|>
Bạn là một trợ lí AI hữu ích. Hãy giúp đỡ người dùng càng chính xác càng tốt</s>
<|plugins|>
[{"type": "function", "function": {"name": "add_two_number", "description": "add two number x and y", "parameters": {"type": "object", "properties": {"x": {"type": "number", "description": "first number", "required": true}, "y": {"type": "number", "description": "second number", "required": true}}}}}]
Standards for using the tool must comply with the following syntax:
[execute]({"type": string, "function": string, "arguments": object})</s>
<|user|>
Hãy tính cho công thức sau 2 + 3</s>
<|assistant|>
[execute]({"type": "function", "function": "add_two_number", "arguments": {"x": 2, "y": 3}})<//></s>
<|tool|>
{"result": 5}</s>
<|user|>
Hãy tính cho công thức sau 4 + 5 + 6</s>
# add_generation_prompt=True
<|system|>
Bạn là một trợ lí AI hữu ích. Hãy giúp đỡ người dùng càng chính xác càng tốt</s>
<|plugins|>
[{"type": "function", "function": {"name": "add_two_number", "description": "add two number x and y", "parameters": {"type": "object", "properties": {"x": {"type": "number", "description": "first number", "required": true}, "y": {"type": "number", "description": "second number", "required": true}}}}}]
Standards for using the tool must comply with the following syntax:
[execute]({"type": string, "function": string, "arguments": object})</s>
<|user|>
Hãy tính cho công thức sau 2 + 3</s>
<|assistant|>
[execute]({"type": "function", "function": "add_two_number", "arguments": {"x": 2, "y": 3}})<//></s>
<|tool|>
{"result": 5}</s>
<|assistant|>
Kết quả của phép tính là 5.</s>
Glad to see it was useful to you.
@lamhieu Yeah! Your model is great but it needs to be trained more for this task. I just found a bug
<|system|>
Bạn là một trợ lí AI hữu ích. Hãy giúp đỡ người dùng càng chính xác càng tốt</s>
<|plugins|>
[{"type": "function", "function": {"name": "add_two_number", "description": "add two number x and y", "parameters": {"type": "object", "properties": {"x": {"type": "number", "description": "first number", "required": true}, "y": {"type": "number", "description": "second number", "required": true}}}}}]
Standards for using the tool must comply with the following syntax:
[execute]({"type": string, "function": string, "arguments": object})</s>
<|user|>
Hãy tính cho công thức sau 2 + 3</s>
<|assistant|>
[execute]({"type": "funcition", "function": "add_two_number", "arguments": {"x": 2, "y": 3}})<//></s>
<|tool|>
{"results": 5}</s>
<|assistant|>
Kết quả của phép tính là 5.</s></s>
<|user|>
Vậy tổng của 5000 và 4929 bằng bao nhiêu ?</s>
<|assistant|>
[execute]({"type": "funcition", "function": "add_two_number", "arguments": {"x": 5000, "y": 4929}})<//></s>
<|tool|>
{"results": 9929}</s>
<|assistant|>
Tổng của 5000 và 4929 bằng 9929.</s></s>
<|user|>
Cảm ơn nhé</s>
<|assistant|>
Không có gì, bạn cần thêm gì nữa không ?</s></s>
<|user|>
Hồ Chí Minh là ai ?</s>
<|assistant|>
[execute]({"type": "funcition", "function": "who_is_ho_chi_minh", "arguments": {}}) <//>
**Hồ Chí Minh (1890-1969)** là một nhà lãnh tụ cách mạng, chính trị gia và nhà hoạt động xã hội Việt Nam. Ông là người sáng lập và lãnh tổ Đảng Cộng sản Việt Nam, Chủ tịch nước Cộng hòa miền Nam Việt Nam (1954-1969), Chủ tịch nước Cộng hòa miền Bắc Việt Nam (1945-1946) và Tổng Bí thư Ban Chấp hành Trung ương Đảng Cộng sản Việt Nam (1941-1969). Hồ Chí Minh được coi là một trong những nhân vật quan trọng nhất trong lịch sử Việt Nam, cũng như là một nhà lãnh tụ vĩ đại thế giới.</s></s>
For longer conversations, it cannot handle function as well as a single turn anymore. Hallucination happens and the results are messed up.
Anyway, thanks for your contribution !!!
Yes, "<//>" can be used to stop earlier when generating text. If I know about this problem, I will offer a more practical solution. Many thanks ~
But if you look again, why does </s></s> appear? It could be something wrong when you use it.