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.
Usage
python
1from transformers import AutoTokenizer, AutoModelForCausalLM
23model_name ='mllmTeam/PhoneLM-1.5B-Call'4system_prompt ="You are an expert in composing functions."56user_message ="""
7Here is a list of functions:
89Name:
10 web_search
11Description:
12 Initiates a web search using the specified query.
1314This function starts a web search using the default search engine.
15It opens the search results in the default web browser or appropriate search application.
16Args:
17 query (str): The search string or keywords to be used for the web search.
18 engine (str): The search engine to use. Default is "baidu".
19Possible values are: "baidu", "google"
20Returns:
21 None
22Example:
23 # Perform a simple web search
24web_search("Python programming tutorials")
2526# Search for a phrase
27web_search('"to be or not to be"')
2829# Search using a specific search engine
30web_search("Python programming tutorials", "google")
313233Now my query is: Help me search the president of United State
34"""3536prompt =[37{"role":"system","content": system_prompt},38{"role":"user","content": user_message}39]4041model = AutoModelForCausalLM.from_pretrained(model_name, device_map='cuda', trust_remote_code=True)4243tokenizer = AutoTokenizer.from_pretrained(model_name)44input_text = tokenizer.apply_chat_template(prompt, tokenize=False, add_generation_prompt=True)4546inp = tokenizer(input_text, return_tensors="pt")47inp ={k: v.to('cuda')for k, v in inp.items()}48out = model.generate(**inp,49 max_length=1000,50 do_sample=True,51 temperature=0.7,52 top_p=0.753)54text = tokenizer.decode(out[0], skip_special_tokens=True)55print(text)
Model Details
Developed by: mllmTeam
Model type: 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
Position Embeddings: Rotary Position Embeddings (Su et al., 2021) applied to the first 25% of head embedding dimensions for improved throughput following Black et al. (2022). PhoneLM quantized the sin and cos values in Rotary Position Embeddings to 8-bit integers.
Biases: We remove all bias terms from the feed-forward networks and multi-head self-attention layers, except for the biases of the query, key, and value projections (Bai et al., 2023).
ReLU Activation Function: ReLU(Glorot et al., 2011) activation functions are adopted in feed-forward networks.
Tokenizer: We use the SmolLM(Allal et al., 2024)'s tokenizer with a vocabulary size of 49,152.
License
This repository is released under the Apache-2.0 License.
Citation
@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},
}