Text Generation
Transformers
Safetensors
English
llama4_text
finance
financial-sentiment
sentiment-analysis
chain-of-thought
reasoning
grpo
sft
lora
finsenti
conversational
Instructions to use Ayansk11/FinSenti-MobileLLM-R1-950M with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Ayansk11/FinSenti-MobileLLM-R1-950M with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Ayansk11/FinSenti-MobileLLM-R1-950M") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("Ayansk11/FinSenti-MobileLLM-R1-950M") model = AutoModelForCausalLM.from_pretrained("Ayansk11/FinSenti-MobileLLM-R1-950M", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Ayansk11/FinSenti-MobileLLM-R1-950M with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Ayansk11/FinSenti-MobileLLM-R1-950M" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Ayansk11/FinSenti-MobileLLM-R1-950M", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Ayansk11/FinSenti-MobileLLM-R1-950M
- SGLang
How to use Ayansk11/FinSenti-MobileLLM-R1-950M 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 "Ayansk11/FinSenti-MobileLLM-R1-950M" \ --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": "Ayansk11/FinSenti-MobileLLM-R1-950M", "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 "Ayansk11/FinSenti-MobileLLM-R1-950M" \ --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": "Ayansk11/FinSenti-MobileLLM-R1-950M", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use Ayansk11/FinSenti-MobileLLM-R1-950M with Docker Model Runner:
docker model run hf.co/Ayansk11/FinSenti-MobileLLM-R1-950M
Upload folder using huggingface_hub
Browse files- chat_template.jinja +8 -88
- config.json +4 -8
- generation_config.json +3 -0
- model.safetensors +2 -2
chat_template.jinja
CHANGED
|
@@ -1,91 +1,11 @@
|
|
| 1 |
-
{{
|
| 2 |
-
{
|
| 3 |
-
{%- set tools = custom_tools %}
|
| 4 |
-
{%- endif %}
|
| 5 |
-
{%- if not tools_in_user_message is defined %}
|
| 6 |
-
{%- set tools_in_user_message = true %}
|
| 7 |
-
{%- endif %}
|
| 8 |
-
{%- if not date_string is defined %}
|
| 9 |
-
{%- if strftime_now is defined %}
|
| 10 |
-
{%- set date_string = strftime_now("%d %b %Y") %}
|
| 11 |
-
{%- else %}
|
| 12 |
-
{%- set date_string = "26 Jul 2024" %}
|
| 13 |
-
{%- endif %}
|
| 14 |
-
{%- endif %}
|
| 15 |
-
{%- if not tools is defined %}
|
| 16 |
-
{%- set tools = none %}
|
| 17 |
-
{%- endif %}
|
| 18 |
|
| 19 |
-
{
|
| 20 |
-
{
|
| 21 |
-
{%- set system_message = messages[0]['content']|trim %}
|
| 22 |
-
{%- set messages = messages[1:] %}
|
| 23 |
-
{%- else %}
|
| 24 |
-
{%- set system_message = "Please reason step by step, and put your final answer within \\boxed{}." %}
|
| 25 |
-
{%- endif %}
|
| 26 |
|
| 27 |
-
{
|
| 28 |
-
{{
|
| 29 |
-
{%- if tools is not none %}
|
| 30 |
-
{{- "Environment: ipython\n" }}
|
| 31 |
-
{%- endif %}
|
| 32 |
-
{%- if tools is not none and not tools_in_user_message %}
|
| 33 |
-
{{- "You have access to the following functions. To call a function, please respond with JSON for a function call." }}
|
| 34 |
-
{{- 'Respond in the format {"name": function name, "parameters": dictionary of argument name and its value}.' }}
|
| 35 |
-
{{- "Do not use variables.\n\n" }}
|
| 36 |
-
{%- for t in tools %}
|
| 37 |
-
{{- t | tojson(indent=4) }}
|
| 38 |
-
{{- "\n\n" }}
|
| 39 |
-
{%- endfor %}
|
| 40 |
-
{%- endif %}
|
| 41 |
-
{{- system_message }}
|
| 42 |
-
{{- "<|eot_id|>" }}
|
| 43 |
|
| 44 |
-
{
|
| 45 |
-
{%
|
| 46 |
-
{#- Extract the first user message so we can plug it in here #}
|
| 47 |
-
{%- if messages | length != 0 %}
|
| 48 |
-
{%- set first_user_message = messages[0]['content']|trim %}
|
| 49 |
-
{%- set messages = messages[1:] %}
|
| 50 |
-
{%- else %}
|
| 51 |
-
{{- raise_exception("Cannot put tools in the first user message when there's no first user message!") }}
|
| 52 |
-
{%- endif %}
|
| 53 |
-
{{- '<|start_header_id|>user<|end_header_id|>\n\n' -}}
|
| 54 |
-
{{- "Given the following functions, please respond with a JSON for a function call " }}
|
| 55 |
-
{{- "with its proper arguments that best answers the given prompt.\n\n" }}
|
| 56 |
-
{{- 'Respond in the format {"name": function name, "parameters": dictionary of argument name and its value}.' }}
|
| 57 |
-
{{- "Do not use variables.\n\n" }}
|
| 58 |
-
{%- for t in tools %}
|
| 59 |
-
{{- t | tojson(indent=4) }}
|
| 60 |
-
{{- "\n\n" }}
|
| 61 |
-
{%- endfor %}
|
| 62 |
-
{{- first_user_message + "<|eot_id|>"}}
|
| 63 |
-
{%- endif %}
|
| 64 |
-
|
| 65 |
-
{%- for message in messages %}
|
| 66 |
-
{%- if not (message.role == 'ipython' or message.role == 'tool' or 'tool_calls' in message) %}
|
| 67 |
-
{{- '<|start_header_id|>' + message['role'] + '<|end_header_id|>\n\n'+ message['content'] | trim + '<|eot_id|>' }}
|
| 68 |
-
{%- elif 'tool_calls' in message %}
|
| 69 |
-
{%- if not message.tool_calls|length == 1 %}
|
| 70 |
-
{{- raise_exception("This model only supports single tool-calls at once!") }}
|
| 71 |
-
{%- endif %}
|
| 72 |
-
{%- set tool_call = message.tool_calls[0].function %}
|
| 73 |
-
{{- '<|start_header_id|>assistant<|end_header_id|>\n\n' -}}
|
| 74 |
-
{{- '{"name": "' + tool_call.name + '", ' }}
|
| 75 |
-
{{- '"parameters": ' }}
|
| 76 |
-
{{- tool_call.arguments | tojson }}
|
| 77 |
-
{{- "}" }}
|
| 78 |
-
{{- "<|eot_id|>" }}
|
| 79 |
-
{%- elif message.role == "tool" or message.role == "ipython" %}
|
| 80 |
-
{{- "<|start_header_id|>ipython<|end_header_id|>\n\n" }}
|
| 81 |
-
{%- if message.content is mapping or message.content is iterable %}
|
| 82 |
-
{{- message.content | tojson }}
|
| 83 |
-
{%- else %}
|
| 84 |
-
{{- message.content }}
|
| 85 |
-
{%- endif %}
|
| 86 |
-
{{- "<|eot_id|>" }}
|
| 87 |
-
{%- endif %}
|
| 88 |
-
{%- endfor %}
|
| 89 |
-
{%- if add_generation_prompt %}
|
| 90 |
-
{{- '<|start_header_id|>assistant<|end_header_id|>\n\n' }}
|
| 91 |
-
{%- endif %}
|
|
|
|
| 1 |
+
{% for message in messages %}{% if message['role'] == 'system' %}### System
|
| 2 |
+
{{ message['content'] }}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
|
| 4 |
+
{% elif message['role'] == 'user' %}### Input
|
| 5 |
+
{{ message['content'] }}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
+
{% elif message['role'] == 'assistant' %}### Response
|
| 8 |
+
{{ message['content'] }}{{ eos_token }}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
+
{% endif %}{% endfor %}{% if add_generation_prompt %}### Response
|
| 11 |
+
{% endif %}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
config.json
CHANGED
|
@@ -9,11 +9,7 @@
|
|
| 9 |
"attn_temperature_tuning": false,
|
| 10 |
"bos_token_id": 128000,
|
| 11 |
"dtype": "bfloat16",
|
| 12 |
-
"eos_token_id":
|
| 13 |
-
128001,
|
| 14 |
-
128008,
|
| 15 |
-
128009
|
| 16 |
-
],
|
| 17 |
"floor_scale": 8192,
|
| 18 |
"for_llm_compressor": false,
|
| 19 |
"head_dim": 64,
|
|
@@ -80,7 +76,7 @@
|
|
| 80 |
"num_key_value_heads": 6,
|
| 81 |
"num_local_experts": 0,
|
| 82 |
"output_router_logits": false,
|
| 83 |
-
"pad_token_id":
|
| 84 |
"rms_norm_eps": 1e-05,
|
| 85 |
"rope_parameters": {
|
| 86 |
"rope_theta": 8000000.0,
|
|
@@ -88,9 +84,9 @@
|
|
| 88 |
},
|
| 89 |
"router_aux_loss_coef": 0.001,
|
| 90 |
"router_jitter_noise": 0.0,
|
| 91 |
-
"tie_word_embeddings":
|
| 92 |
"transformers_version": "5.2.0",
|
| 93 |
-
"use_cache":
|
| 94 |
"use_qk_norm": true,
|
| 95 |
"vocab_size": 128257
|
| 96 |
}
|
|
|
|
| 9 |
"attn_temperature_tuning": false,
|
| 10 |
"bos_token_id": 128000,
|
| 11 |
"dtype": "bfloat16",
|
| 12 |
+
"eos_token_id": 128009,
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
"floor_scale": 8192,
|
| 14 |
"for_llm_compressor": false,
|
| 15 |
"head_dim": 64,
|
|
|
|
| 76 |
"num_key_value_heads": 6,
|
| 77 |
"num_local_experts": 0,
|
| 78 |
"output_router_logits": false,
|
| 79 |
+
"pad_token_id": 128256,
|
| 80 |
"rms_norm_eps": 1e-05,
|
| 81 |
"rope_parameters": {
|
| 82 |
"rope_theta": 8000000.0,
|
|
|
|
| 84 |
},
|
| 85 |
"router_aux_loss_coef": 0.001,
|
| 86 |
"router_jitter_noise": 0.0,
|
| 87 |
+
"tie_word_embeddings": false,
|
| 88 |
"transformers_version": "5.2.0",
|
| 89 |
+
"use_cache": false,
|
| 90 |
"use_qk_norm": true,
|
| 91 |
"vocab_size": 128257
|
| 92 |
}
|
generation_config.json
CHANGED
|
@@ -3,9 +3,12 @@
|
|
| 3 |
"bos_token_id": 128000,
|
| 4 |
"cache_implementation": "dynamic",
|
| 5 |
"eos_token_id": [
|
|
|
|
| 6 |
128001,
|
| 7 |
128008,
|
| 8 |
128009
|
| 9 |
],
|
|
|
|
|
|
|
| 10 |
"transformers_version": "5.2.0"
|
| 11 |
}
|
|
|
|
| 3 |
"bos_token_id": 128000,
|
| 4 |
"cache_implementation": "dynamic",
|
| 5 |
"eos_token_id": [
|
| 6 |
+
128009,
|
| 7 |
128001,
|
| 8 |
128008,
|
| 9 |
128009
|
| 10 |
],
|
| 11 |
+
"pad_token_id": 128256,
|
| 12 |
+
"tie_word_embeddings": false,
|
| 13 |
"transformers_version": "5.2.0"
|
| 14 |
}
|
model.safetensors
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a0d55067d35d4254ad193dc4e5b01475718ef9fcf94e7aa276c42d86ec9a4e4a
|
| 3 |
+
size 2293403880
|