Instructions to use 0xtaipoian/open-lilm-v2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use 0xtaipoian/open-lilm-v2 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="0xtaipoian/open-lilm-v2") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("0xtaipoian/open-lilm-v2") model = AutoModelForCausalLM.from_pretrained("0xtaipoian/open-lilm-v2") 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 0xtaipoian/open-lilm-v2 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "0xtaipoian/open-lilm-v2" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "0xtaipoian/open-lilm-v2", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/0xtaipoian/open-lilm-v2
- SGLang
How to use 0xtaipoian/open-lilm-v2 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 "0xtaipoian/open-lilm-v2" \ --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": "0xtaipoian/open-lilm-v2", "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 "0xtaipoian/open-lilm-v2" \ --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": "0xtaipoian/open-lilm-v2", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use 0xtaipoian/open-lilm-v2 with Docker Model Runner:
docker model run hf.co/0xtaipoian/open-lilm-v2
open-lilm-v2
Version 1 can be found here.
Warning: Due to the nature of the training data, this model is highly likely to return violent, racist and discriminative content. DO NOT USE IN PRODUCTION ENVIRONMENT.
Inspired by another project. This is a finetuned model based on CantoneseLLMChat-v0.5 which everybody can use without the need for a Mac with 128GB RAM.
Following the same principle, we filtered 1,916,944 post and reply pairs in LIHKG forum from the LIHKG Dataset and scrapped from the site for the latest posts.
- Reply must be a direct reply to the original post by a user other than the author
- The total number of reactions (positive or negative) must be larger than 20
- The post and reply pair has to be shorter than 2048 words
To avoid political complications, the dataset will not be made publicly available.
Compared to version 1,
- Training sample increased from 377,595 to 1,916,944, including the latest posts
- Removed all URLs
- Removed comments with only emojis
Intended uses & limitations
Due to the nature of an online and anonymous forum, the training data and the model are full of rude, violent, racist and discriminative language. This model is only intended for research or entertainment purposes.
The comments on LIHKG also tend to be very short. Thus the model cannot generate anything more than a line.
How to use it?
You can run it on Colab or anywhere you want based on the code:
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig, LlamaTokenizer, GenerationConfig, pipeline
from peft import PeftModel, PeftMixedModel
import torch
model_name = "0xtaipoian/open-lilm-v2"
bnb_config = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_use_double_quant=True,
bnb_4bit_quant_type="nf4",
bnb_4bit_compute_dtype=torch.bfloat16
)
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(
model_name,
torch_dtype=torch.bfloat16,
trust_remote_code=True,
quantization_config=bnb_config,
)
def chat(messages, temperature=0.9, max_new_tokens=200):
input_ids = tokenizer.apply_chat_template(conversation=messages, tokenize=True, add_generation_prompt=True, return_tensors='pt').to('cuda:0')
output_ids = model.generate(input_ids, max_new_tokens=max_new_tokens, temperature=temperature, do_sample=True)
chatml = tokenizer.apply_chat_template(messages, add_generation_prompt=True, tokenize=False)
print(chatml)
response = tokenizer.decode(output_ids[0][input_ids.shape[1]:], skip_special_tokens=False)
return response
messages = [
# {"role": "system", "content": ""},
{"role": "user",
"content":
"""
密陽44人輪姦案」受害女隔20年現身:時間停在2004,不記得
"""}]
result = chat(messages, max_new_tokens=200, temperature=1)
print(result)
Training Procedures
The model was trained for 11 hours on 8 NVIDIA H100 80GB HBM3 GPUs with LLaMA-Factory.
The following hyperparameters were used during training:
- learning_rate: 1e-05
- train_batch_size: 22
- seed: 42
- gradient_accumulation_steps: 22
- total_train_batch_size: 3872
- num_epochs: 1.0
- Downloads last month
- 4