Views
No views yet
internlm2_5-7b-chat model in GGUF format can be utilized by llama.cpp, a highly popular open-source framework for Large Language Model (LLM) inference, across a variety of hardware platforms, both locally and in the cloud.
This repository offers internlm2_5-7b-chat models in GGUF format in both half precision and various low-bit quantized versions, including q5_0, q5_k_m, q6_k, and q8_0.llama.cpp from source. The following code snippet provides an example for the Linux CUDA platform. For instructions on other platforms, please refer to the official guide.1conda create --name internlm2 python=3.10 -y
2conda activate internlm2
3pip install cmake1git clone --depth=1 https://github.com/ggerganov/llama.cpp.git
2cd llama.cpp
3cmake -B build -DGGML_CUDA=ON
4cmake --build build --config Release -jbuild/binllama.cpp.internlm2_5-7b-chat-fp16.gguf can be downloaded as below:1pip install huggingface-hub
2huggingface-cli download internlm/internlm2_5-7b-chat-gguf internlm2_5-7b-chat-fp16.gguf --local-dir . --local-dir-use-symlinks Falsellama-cli for conducting inference. For a detailed explanation of llama-cli, please refer to this guide1build/bin/llama-cli \
2 --model internlm2_5-7b-chat-fp16.gguf \
3 --predict 512 \
4 --ctx-size 4096 \
5 --gpu-layers 32 \
6 --temp 0.8 \
7 --top-p 0.8 \
8 --top-k 50 \
9 --seed 1024 \
10 --color \
11 --prompt "<|im_start|>system\nYou are an AI assistant whose name is InternLM (书生·浦语).\n- InternLM (书生·浦语) is a conversational language model that is developed by Shanghai AI Laboratory (上海人工智能实验室). It is designed to be helpful, honest, and harmless.\n- InternLM (书生·浦语) can understand and communicate fluently in the language chosen by the user such as English and 中文.<|im_end|>\n" \
12 --interactive \
13 --multiline-input \
14 --conversation \
15 --verbose \
16 --logdir workdir/logdir \
17 --in-prefix "<|im_start|>user\n" \
18 --in-suffix "<|im_end|>\n<|im_start|>assistant\n"llama-cli example:1build/bin/llama-cli \
2 --model internlm2_5-7b-chat-fp16.gguf \
3 --predict 512 \
4 --ctx-size 4096 \
5 --gpu-layers 32 \
6 --temp 0.8 \
7 --top-p 0.8 \
8 --top-k 50 \
9 --seed 1024 \
10 --color \
11 --prompt '<|im_start|>system\nYou are InternLM2-Chat, a harmless AI assistant.<|im_end|>\n<|im_start|>system name=<|plugin|>[{"name": "get_current_weather", "parameters": {"required": ["location"], "type": "object", "properties": {"location": {"type": "string", "description": "The city and state, e.g. San Francisco, CA"}, "unit": {"type": "string"}}}, "description": "Get the current weather in a given location"}]<|im_end|>\n<|im_start|>user\n' \
12 --interactive \
13 --multiline-input \
14 --conversation \
15 --verbose \
16 --in-suffix "<|im_end|>\n<|im_start|>assistant\n" \
17 --special1<s><|im_start|>system
2You are InternLM2-Chat, a harmless AI assistant.<|im_end|>
3<|im_start|>system name=<|plugin|>[{"name": "get_current_weather", "parameters": {"required": ["location"], "type": "object", "properties": {"location": {"type": "string", "description": "The city and state, e.g. San Francisco, CA"}, "unit": {"type": "string"}}}, "description": "Get the current weather in a given location"}]<|im_end|>
4<|im_start|>user
5
6> I want to know today's weather in Shanghai
7I need to use the get_current_weather function to get the current weather in Shanghai.<|action_start|><|plugin|>
8{"name": "get_current_weather", "parameters": {"location": "Shanghai"}}<|action_end|>
9<|im_end|>
10
11> <|im_start|>environment name=<|plugin|>\n{"temperature": 22}
12The current temperature in Shanghai is 22 degrees Celsius.<|im_end|>
13
14> llama.cpp provides an OpenAI API compatible server - llama-server. You can deploy internlm2_5-7b-chat-fp16.gguf into a service like this:./build/bin/llama-server -m ./internlm2_5-7b-chat-fp16.gguf -ngl 321from openai import OpenAI
2client = OpenAI(
3 api_key='YOUR_API_KEY',
4 base_url='http://localhost:8080/v1'
5)
6model_name = client.models.list().data[0].id
7response = client.chat.completions.create(
8 model=model_name,
9 messages=[
10 {"role": "system", "content": "You are a helpful assistant."},
11 {"role": "user", "content": " provide three suggestions about time management"},
12 ],
13 temperature=0.8,
14 top_p=0.8
15)
16print(response)