Text Generation
Transformers
Safetensors
GGUF
stablelm
HelpingAI
Emotionally Intelligent
EQ
conversational
imatrix
Instructions to use OEvortex/HelpingAI-3B-chat with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use OEvortex/HelpingAI-3B-chat with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="OEvortex/HelpingAI-3B-chat") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForMultimodalLM tokenizer = AutoTokenizer.from_pretrained("OEvortex/HelpingAI-3B-chat") model = AutoModelForMultimodalLM.from_pretrained("OEvortex/HelpingAI-3B-chat") 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]:])) - llama-cpp-python
How to use OEvortex/HelpingAI-3B-chat with llama-cpp-python:
# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="OEvortex/HelpingAI-3B-chat", filename="helpingai-3b-chat-iq4_xs-imat.gguf", )
llm.create_chat_completion( messages = [ { "role": "user", "content": "What is the capital of France?" } ] ) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use OEvortex/HelpingAI-3B-chat with llama.cpp:
Install from brew
brew install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf OEvortex/HelpingAI-3B-chat:IQ4_XS # Run inference directly in the terminal: llama-cli -hf OEvortex/HelpingAI-3B-chat:IQ4_XS
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf OEvortex/HelpingAI-3B-chat:IQ4_XS # Run inference directly in the terminal: llama-cli -hf OEvortex/HelpingAI-3B-chat:IQ4_XS
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf OEvortex/HelpingAI-3B-chat:IQ4_XS # Run inference directly in the terminal: ./llama-cli -hf OEvortex/HelpingAI-3B-chat:IQ4_XS
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf OEvortex/HelpingAI-3B-chat:IQ4_XS # Run inference directly in the terminal: ./build/bin/llama-cli -hf OEvortex/HelpingAI-3B-chat:IQ4_XS
Use Docker
docker model run hf.co/OEvortex/HelpingAI-3B-chat:IQ4_XS
- LM Studio
- Jan
- vLLM
How to use OEvortex/HelpingAI-3B-chat with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "OEvortex/HelpingAI-3B-chat" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "OEvortex/HelpingAI-3B-chat", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/OEvortex/HelpingAI-3B-chat:IQ4_XS
- SGLang
How to use OEvortex/HelpingAI-3B-chat 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 "OEvortex/HelpingAI-3B-chat" \ --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": "OEvortex/HelpingAI-3B-chat", "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 "OEvortex/HelpingAI-3B-chat" \ --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": "OEvortex/HelpingAI-3B-chat", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Ollama
How to use OEvortex/HelpingAI-3B-chat with Ollama:
ollama run hf.co/OEvortex/HelpingAI-3B-chat:IQ4_XS
- Unsloth Studio
How to use OEvortex/HelpingAI-3B-chat with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for OEvortex/HelpingAI-3B-chat to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for OEvortex/HelpingAI-3B-chat to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for OEvortex/HelpingAI-3B-chat to start chatting
- Atomic Chat new
- Docker Model Runner
How to use OEvortex/HelpingAI-3B-chat with Docker Model Runner:
docker model run hf.co/OEvortex/HelpingAI-3B-chat:IQ4_XS
- Lemonade
How to use OEvortex/HelpingAI-3B-chat with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull OEvortex/HelpingAI-3B-chat:IQ4_XS
Run and chat with the model
lemonade run user.HelpingAI-3B-chat-IQ4_XS
List all available models
lemonade list
Upload tokenization_HelpingAI_fast.py
Browse files- tokenization_HelpingAI_fast.py +144 -0
tokenization_HelpingAI_fast.py
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
import json
|
| 3 |
+
from typing import List, Optional, Tuple
|
| 4 |
+
|
| 5 |
+
from tokenizers import pre_tokenizers, processors
|
| 6 |
+
|
| 7 |
+
from transformers.tokenization_utils_fast import PreTrainedTokenizerFast
|
| 8 |
+
from transformers.utils import logging
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
logger = logging.get_logger(__name__)
|
| 12 |
+
|
| 13 |
+
VOCAB_FILES_NAMES = {"vocab_file": "vocab.json", "merges_file": "merges.txt", "tokenizer_file": "tokenizer.json"}
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
class HelpingAITokenizerFast(PreTrainedTokenizerFast):
|
| 17 |
+
vocab_files_names = VOCAB_FILES_NAMES
|
| 18 |
+
model_input_names = ["input_ids", "attention_mask"]
|
| 19 |
+
|
| 20 |
+
def __init__(
|
| 21 |
+
self,
|
| 22 |
+
vocab_file=None,
|
| 23 |
+
merges_file=None,
|
| 24 |
+
tokenizer_file=None,
|
| 25 |
+
unk_token="<|endoftext|>",
|
| 26 |
+
bos_token="<|im_start|>",
|
| 27 |
+
eos_token="<|im_end|>",
|
| 28 |
+
pad_token="<|im_end|>",
|
| 29 |
+
add_bos_token=False,
|
| 30 |
+
add_eos_token=False,
|
| 31 |
+
add_prefix_space=False,
|
| 32 |
+
**kwargs,
|
| 33 |
+
):
|
| 34 |
+
super().__init__(
|
| 35 |
+
vocab_file,
|
| 36 |
+
merges_file,
|
| 37 |
+
tokenizer_file=tokenizer_file,
|
| 38 |
+
unk_token=unk_token,
|
| 39 |
+
bos_token=bos_token,
|
| 40 |
+
eos_token=eos_token,
|
| 41 |
+
pad_token=pad_token,
|
| 42 |
+
add_bos_token=add_bos_token,
|
| 43 |
+
add_eos_token=add_eos_token,
|
| 44 |
+
add_prefix_space=add_prefix_space,
|
| 45 |
+
**kwargs,
|
| 46 |
+
)
|
| 47 |
+
|
| 48 |
+
self._add_bos_token = add_bos_token
|
| 49 |
+
self._add_eos_token = add_eos_token
|
| 50 |
+
self.update_post_processor()
|
| 51 |
+
|
| 52 |
+
pre_tok_state = json.loads(self.backend_tokenizer.pre_tokenizer.__getstate__())
|
| 53 |
+
if pre_tok_state.get("add_prefix_space", add_prefix_space) != add_prefix_space:
|
| 54 |
+
pre_tok_class = getattr(pre_tokenizers, pre_tok_state.pop("type"))
|
| 55 |
+
pre_tok_state["add_prefix_space"] = add_prefix_space
|
| 56 |
+
self.backend_tokenizer.pre_tokenizer = pre_tok_class(**pre_tok_state)
|
| 57 |
+
|
| 58 |
+
self.add_prefix_space = add_prefix_space
|
| 59 |
+
|
| 60 |
+
@property
|
| 61 |
+
def add_eos_token(self):
|
| 62 |
+
return self._add_eos_token
|
| 63 |
+
|
| 64 |
+
@property
|
| 65 |
+
def add_bos_token(self):
|
| 66 |
+
return self._add_bos_token
|
| 67 |
+
|
| 68 |
+
@add_eos_token.setter
|
| 69 |
+
def add_eos_token(self, value):
|
| 70 |
+
self._add_eos_token = value
|
| 71 |
+
self.update_post_processor()
|
| 72 |
+
|
| 73 |
+
@add_bos_token.setter
|
| 74 |
+
def add_bos_token(self, value):
|
| 75 |
+
self._add_bos_token = value
|
| 76 |
+
self.update_post_processor()
|
| 77 |
+
|
| 78 |
+
def update_post_processor(self):
|
| 79 |
+
bos = self.bos_token
|
| 80 |
+
bos_token_id = self.bos_token_id
|
| 81 |
+
if bos is None and self.add_bos_token:
|
| 82 |
+
raise ValueError("add_bos_token = True but bos_token = None")
|
| 83 |
+
|
| 84 |
+
eos = self.eos_token
|
| 85 |
+
eos_token_id = self.eos_token_id
|
| 86 |
+
if eos is None and self.add_eos_token:
|
| 87 |
+
raise ValueError("add_eos_token = True but eos_token = None")
|
| 88 |
+
|
| 89 |
+
single = f"{(bos+':0 ') if self.add_bos_token else ''}$A:0{(' '+eos+':0') if self.add_eos_token else ''}"
|
| 90 |
+
pair = f"{single}{(' '+bos+':1') if self.add_bos_token else ''} $B:1{(' '+eos+':1') if self.add_eos_token else ''}"
|
| 91 |
+
|
| 92 |
+
special_tokens = []
|
| 93 |
+
if self.add_bos_token:
|
| 94 |
+
special_tokens.append((bos, bos_token_id))
|
| 95 |
+
if self.add_eos_token:
|
| 96 |
+
special_tokens.append((eos, eos_token_id))
|
| 97 |
+
self._tokenizer.post_processor = processors.TemplateProcessing(
|
| 98 |
+
single=single, pair=pair, special_tokens=special_tokens
|
| 99 |
+
)
|
| 100 |
+
|
| 101 |
+
def get_special_tokens_mask(
|
| 102 |
+
self, token_ids_0: List[int], token_ids_1: Optional[List[int]] = None, already_has_special_tokens: bool = False
|
| 103 |
+
) -> List[int]:
|
| 104 |
+
if already_has_special_tokens:
|
| 105 |
+
return super().get_special_tokens_mask(
|
| 106 |
+
token_ids_0=token_ids_0, token_ids_1=token_ids_1, already_has_special_tokens=True
|
| 107 |
+
)
|
| 108 |
+
|
| 109 |
+
bos_token_id = [1] if self.add_bos_token else []
|
| 110 |
+
eos_token_id = [1] if self.add_eos_token else []
|
| 111 |
+
|
| 112 |
+
if token_ids_1 is None:
|
| 113 |
+
return bos_token_id + ([0] * len(token_ids_0)) + eos_token_id
|
| 114 |
+
return (
|
| 115 |
+
bos_token_id
|
| 116 |
+
+ ([0] * len(token_ids_0))
|
| 117 |
+
+ eos_token_id
|
| 118 |
+
+ bos_token_id
|
| 119 |
+
+ ([0] * len(token_ids_1))
|
| 120 |
+
+ eos_token_id
|
| 121 |
+
)
|
| 122 |
+
|
| 123 |
+
def build_inputs_with_special_tokens(self, token_ids_0, token_ids_1=None):
|
| 124 |
+
bos_token_id = [self.bos_token_id] if self.add_bos_token else []
|
| 125 |
+
eos_token_id = [self.eos_token_id] if self.add_eos_token else []
|
| 126 |
+
|
| 127 |
+
output = bos_token_id + token_ids_0 + eos_token_id
|
| 128 |
+
|
| 129 |
+
if token_ids_1 is not None:
|
| 130 |
+
output = output + bos_token_id + token_ids_1 + eos_token_id
|
| 131 |
+
|
| 132 |
+
return output
|
| 133 |
+
|
| 134 |
+
def save_vocabulary(self, save_directory: str, filename_prefix: Optional[str] = None) -> Tuple[str]:
|
| 135 |
+
files = self._tokenizer.model.save(save_directory, name=filename_prefix)
|
| 136 |
+
return tuple(files)
|
| 137 |
+
|
| 138 |
+
@property
|
| 139 |
+
def default_chat_template(self):
|
| 140 |
+
return "{% for message in messages %}{{'<|im_start|>' + message['role'] + '\n' + message['content'] + '<|im_end|>' + '\n'}}{% endfor %}{% if add_generation_prompt %}{{ '<|im_start|>assistant\n' }}{% endif %}"
|
| 141 |
+
|
| 142 |
+
"""
|
| 143 |
+
Tool call template not added
|
| 144 |
+
"""
|