Instructions to use AnirbanSaha/gemma2-2b-tlink with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use AnirbanSaha/gemma2-2b-tlink with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="AnirbanSaha/gemma2-2b-tlink") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("AnirbanSaha/gemma2-2b-tlink") model = AutoModelForCausalLM.from_pretrained("AnirbanSaha/gemma2-2b-tlink", 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 AnirbanSaha/gemma2-2b-tlink with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "AnirbanSaha/gemma2-2b-tlink" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "AnirbanSaha/gemma2-2b-tlink", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/AnirbanSaha/gemma2-2b-tlink
- SGLang
How to use AnirbanSaha/gemma2-2b-tlink 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 "AnirbanSaha/gemma2-2b-tlink" \ --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": "AnirbanSaha/gemma2-2b-tlink", "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 "AnirbanSaha/gemma2-2b-tlink" \ --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": "AnirbanSaha/gemma2-2b-tlink", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use AnirbanSaha/gemma2-2b-tlink with Docker Model Runner:
docker model run hf.co/AnirbanSaha/gemma2-2b-tlink
Gemma-2-2B Temporal Link Classification
Full fine-tuned version of
google/gemma-2-2b-it
on the
fahmidiqbal/tlink-classification
dataset for temporal relation classification.
Task
Given an already-formatted task prompt containing two marked spans
(such as <e1>, <e2>, <t1>, or <t2>), the model generates one
temporal-relation label:
BEFORE— first span occurs earlier than the secondAFTER— first span occurs later than the secondOTHER— overlap or another non-ordering relationNONE— no clear temporal relation
Training Details
| Parameter | Value |
|---|---|
| Base model | google/gemma-2-2b-it |
| Fine-tuning | Full (all parameters) |
| Epochs | 3 |
| Batch size | 8 |
| Learning rate | 2e-5 |
| Weight decay | 0.01 |
| Max length | 2048 |
| Precision | bfloat16 |
| Prompt format | Gemma chat template |
| Dataset | fahmidiqbal/tlink-classification |
Results
Test metrics have not been added yet. Run the evaluation script first to
generate test_metrics.json, then run this upload script again.
Usage
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
MODEL_ID = "AnirbanSaha/gemma2-2b-tlink"
tokenizer = AutoTokenizer.from_pretrained(MODEL_ID)
model = AutoModelForCausalLM.from_pretrained(
MODEL_ID,
dtype=torch.bfloat16,
device_map="auto",
)
model.eval()
prompt = "Your already-formatted temporal relation prompt here..."
messages = [
{"role": "user", "content": prompt}
]
formatted_prompt = tokenizer.apply_chat_template(
messages,
tokenize=False,
add_generation_prompt=True,
)
enc = tokenizer(
formatted_prompt,
add_special_tokens=False,
return_tensors="pt",
).to(model.device)
with torch.inference_mode():
out = model.generate(
**enc,
max_new_tokens=8,
do_sample=False,
pad_token_id=tokenizer.pad_token_id,
eos_token_id=tokenizer.eos_token_id,
)
new_tokens = out[0][enc["input_ids"].shape[1]:]
prediction = tokenizer.decode(
new_tokens,
skip_special_tokens=True,
).strip()
print(prediction)
Base Model License
The base checkpoint uses the Gemma license. Users of this fine-tuned model should review and comply with the applicable Gemma terms.
- Downloads last month
- -
Install from pip and serve model
# Install vLLM from pip: pip install vllm# Start the vLLM server: vllm serve "AnirbanSaha/gemma2-2b-tlink"# Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "AnirbanSaha/gemma2-2b-tlink", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'