mllmTeam/DroidCall
Viewer • Updated • 10.1k • 287 • 3
How to use mllmTeam/PhoneLM-1.5B-Call with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="mllmTeam/PhoneLM-1.5B-Call", trust_remote_code=True)
messages = [
{"role": "user", "content": "Who are you?"},
]
pipe(messages) # Load model directly
from transformers import AutoModelForCausalLM
model = AutoModelForCausalLM.from_pretrained("mllmTeam/PhoneLM-1.5B-Call", trust_remote_code=True, dtype="auto")How to use mllmTeam/PhoneLM-1.5B-Call with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "mllmTeam/PhoneLM-1.5B-Call"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "mllmTeam/PhoneLM-1.5B-Call",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'docker model run hf.co/mllmTeam/PhoneLM-1.5B-Call
How to use mllmTeam/PhoneLM-1.5B-Call with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "mllmTeam/PhoneLM-1.5B-Call" \
--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": "mllmTeam/PhoneLM-1.5B-Call",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'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 "mllmTeam/PhoneLM-1.5B-Call" \
--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": "mllmTeam/PhoneLM-1.5B-Call",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'How to use mllmTeam/PhoneLM-1.5B-Call with Docker Model Runner:
docker model run hf.co/mllmTeam/PhoneLM-1.5B-Call
# Load model directly
from transformers import AutoModelForCausalLM
model = AutoModelForCausalLM.from_pretrained("mllmTeam/PhoneLM-1.5B-Call", trust_remote_code=True, dtype="auto")PhoneLM-1.5B-Call is a 1.5 billion parameter decoder-only language model, fined-turned from PhoneLM-1.5B-Instruct, used for Android intent calling.
from transformers import AutoTokenizer, AutoModelForCausalLM
model_name = 'mllmTeam/PhoneLM-1.5B-Call'
system_prompt = "You are an expert in composing functions."
user_message = """
Here is a list of functions:
Name:
web_search
Description:
Initiates a web search using the specified query.
This function starts a web search using the default search engine.
It opens the search results in the default web browser or appropriate search application.
Args:
query (str): The search string or keywords to be used for the web search.
engine (str): The search engine to use. Default is "baidu".
Possible values are: "baidu", "google"
Returns:
None
Example:
# Perform a simple web search
web_search("Python programming tutorials")
# Search for a phrase
web_search('"to be or not to be"')
# Search using a specific search engine
web_search("Python programming tutorials", "google")
Now my query is: Help me search the president of United State
"""
prompt = [
{"role": "system", "content": system_prompt},
{"role": "user", "content": user_message}
]
model = AutoModelForCausalLM.from_pretrained(model_name, device_map='cuda', trust_remote_code=True)
tokenizer = AutoTokenizer.from_pretrained(model_name)
input_text = tokenizer.apply_chat_template(prompt, tokenize=False, add_generation_prompt=True)
inp = tokenizer(input_text, return_tensors="pt")
inp = {k: v.to('cuda') for k, v in inp.items()}
out = model.generate(**inp,
max_length=1000,
do_sample=True,
temperature=0.7,
top_p=0.7
)
text = tokenizer.decode(out[0], skip_special_tokens=True)
print(text)
PhoneLM 1.5B models are auto-regressive language models based on the transformer decoder architecture.The model is a decoder-only transformer architecture with the following modifications:
| Hidden Size | Layers | Heads | Sequence Length |
|---|---|---|---|
| 2560 | 19 | 16 | 2048 |
@misc{yi2024phonelmanefficientcapablesmall,
title={PhoneLM:an Efficient and Capable Small Language Model Family through Principled Pre-training},
author={Rongjie Yi and Xiang Li and Weikai Xie and Zhenyan Lu and Chenghua Wang and Ao Zhou and Shangguang Wang and Xiwen Zhang and Mengwei Xu},
year={2024},
eprint={2411.05046},
archivePrefix={arXiv},
primaryClass={cs.CL},
url={https://arxiv.org/abs/2411.05046},
}
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="mllmTeam/PhoneLM-1.5B-Call", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)