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") 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
- 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- .gitattributes +1 -0
- chat_template.jinja +91 -0
- config.json +96 -0
- generation_config.json +11 -0
- model.safetensors +3 -0
- tokenizer.json +3 -0
- tokenizer_config.json +21 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
tokenizer.json filter=lfs diff=lfs merge=lfs -text
|
chat_template.jinja
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{{- bos_token }}
|
| 2 |
+
{%- if custom_tools is defined %}
|
| 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 |
+
{#- This block extracts the system message, so we can slot it into the right place. #}
|
| 20 |
+
{%- if messages[0]['role'] == 'system' %}
|
| 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 |
+
{#- System message #}
|
| 28 |
+
{{- "<|start_header_id|>system<|end_header_id|>\n\n" }}
|
| 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 |
+
{#- Custom tools are passed in a user message with some extra guidance #}
|
| 45 |
+
{%- if tools_in_user_message and not tools is none %}
|
| 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 %}
|
config.json
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"architectures": [
|
| 3 |
+
"Llama4ForCausalLM"
|
| 4 |
+
],
|
| 5 |
+
"attention_bias": false,
|
| 6 |
+
"attention_chunk_size": 32768,
|
| 7 |
+
"attention_dropout": 0.0,
|
| 8 |
+
"attn_scale": 0.1,
|
| 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,
|
| 20 |
+
"hidden_act": "silu",
|
| 21 |
+
"hidden_size": 1536,
|
| 22 |
+
"initializer_range": 0.02,
|
| 23 |
+
"interleave_moe_layer_step": 0,
|
| 24 |
+
"intermediate_size": 8192,
|
| 25 |
+
"intermediate_size_mlp": 6144,
|
| 26 |
+
"layer_types": [
|
| 27 |
+
"full_attention",
|
| 28 |
+
"full_attention",
|
| 29 |
+
"full_attention",
|
| 30 |
+
"full_attention",
|
| 31 |
+
"full_attention",
|
| 32 |
+
"full_attention",
|
| 33 |
+
"full_attention",
|
| 34 |
+
"full_attention",
|
| 35 |
+
"full_attention",
|
| 36 |
+
"full_attention",
|
| 37 |
+
"full_attention",
|
| 38 |
+
"full_attention",
|
| 39 |
+
"full_attention",
|
| 40 |
+
"full_attention",
|
| 41 |
+
"full_attention",
|
| 42 |
+
"full_attention",
|
| 43 |
+
"full_attention",
|
| 44 |
+
"full_attention",
|
| 45 |
+
"full_attention",
|
| 46 |
+
"full_attention",
|
| 47 |
+
"full_attention",
|
| 48 |
+
"full_attention"
|
| 49 |
+
],
|
| 50 |
+
"max_position_embeddings": 32768,
|
| 51 |
+
"model_type": "llama4_text",
|
| 52 |
+
"moe_layers": [],
|
| 53 |
+
"no_rope_layers": [
|
| 54 |
+
1,
|
| 55 |
+
1,
|
| 56 |
+
1,
|
| 57 |
+
1,
|
| 58 |
+
1,
|
| 59 |
+
1,
|
| 60 |
+
1,
|
| 61 |
+
1,
|
| 62 |
+
1,
|
| 63 |
+
1,
|
| 64 |
+
1,
|
| 65 |
+
1,
|
| 66 |
+
1,
|
| 67 |
+
1,
|
| 68 |
+
1,
|
| 69 |
+
1,
|
| 70 |
+
1,
|
| 71 |
+
1,
|
| 72 |
+
1,
|
| 73 |
+
1,
|
| 74 |
+
1,
|
| 75 |
+
1
|
| 76 |
+
],
|
| 77 |
+
"num_attention_heads": 24,
|
| 78 |
+
"num_experts_per_tok": 0,
|
| 79 |
+
"num_hidden_layers": 22,
|
| 80 |
+
"num_key_value_heads": 6,
|
| 81 |
+
"num_local_experts": 0,
|
| 82 |
+
"output_router_logits": false,
|
| 83 |
+
"pad_token_id": null,
|
| 84 |
+
"rms_norm_eps": 1e-05,
|
| 85 |
+
"rope_parameters": {
|
| 86 |
+
"rope_theta": 8000000.0,
|
| 87 |
+
"rope_type": "default"
|
| 88 |
+
},
|
| 89 |
+
"router_aux_loss_coef": 0.001,
|
| 90 |
+
"router_jitter_noise": 0.0,
|
| 91 |
+
"tie_word_embeddings": true,
|
| 92 |
+
"transformers_version": "5.2.0",
|
| 93 |
+
"use_cache": true,
|
| 94 |
+
"use_qk_norm": true,
|
| 95 |
+
"vocab_size": 128257
|
| 96 |
+
}
|
generation_config.json
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_from_model_config": true,
|
| 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 |
+
}
|
model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:2ea3c58ccb13fb0c6aabf181308f8d45ddc39d932cf7e4c6638512712f0b9299
|
| 3 |
+
size 1899398184
|
tokenizer.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:6ebafa4822d64592396e4b0264db1bffc05d1765761bef03dfaeb670f93f5f05
|
| 3 |
+
size 17210564
|
tokenizer_config.json
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"backend": "tokenizers",
|
| 3 |
+
"bos_token": "<|begin_of_text|>",
|
| 4 |
+
"clean_up_tokenization_spaces": true,
|
| 5 |
+
"eos_token": "<|eot_id|>",
|
| 6 |
+
"is_local": true,
|
| 7 |
+
"max_length": 512,
|
| 8 |
+
"model_input_names": [
|
| 9 |
+
"input_ids",
|
| 10 |
+
"attention_mask"
|
| 11 |
+
],
|
| 12 |
+
"model_max_length": 32768,
|
| 13 |
+
"pad_to_multiple_of": null,
|
| 14 |
+
"pad_token": "<|finsenti_pad|>",
|
| 15 |
+
"pad_token_type_id": 0,
|
| 16 |
+
"padding_side": "right",
|
| 17 |
+
"stride": 0,
|
| 18 |
+
"tokenizer_class": "TokenizersBackend",
|
| 19 |
+
"truncation_side": "right",
|
| 20 |
+
"truncation_strategy": "longest_first"
|
| 21 |
+
}
|