Instructions to use robinfaro/molm_coadapt with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use robinfaro/molm_coadapt with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="robinfaro/molm_coadapt", trust_remote_code=True)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("robinfaro/molm_coadapt", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use robinfaro/molm_coadapt with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "robinfaro/molm_coadapt" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "robinfaro/molm_coadapt", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/robinfaro/molm_coadapt
- SGLang
How to use robinfaro/molm_coadapt 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 "robinfaro/molm_coadapt" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "robinfaro/molm_coadapt", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'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 "robinfaro/molm_coadapt" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "robinfaro/molm_coadapt", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use robinfaro/molm_coadapt with Docker Model Runner:
docker model run hf.co/robinfaro/molm_coadapt
Adding modeling.py file
Browse files- modeling.py +13 -2
modeling.py
CHANGED
|
@@ -223,8 +223,19 @@ class MoLM(PreTrainedModel):
|
|
| 223 |
# # apply softmax to convert logits to (normalized) probabilities
|
| 224 |
# probs = F.softmax(logits, dim=-1)
|
| 225 |
# # sample from the distribution
|
| 226 |
-
|
| 227 |
-
idx_next = torch.multinomial(probs, num_samples=1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 228 |
# append sampled index to the running sequence and continue
|
| 229 |
idx = torch.cat((idx, idx_next), dim=1)
|
| 230 |
# check if we hit the end of the sequence
|
|
|
|
| 223 |
# # apply softmax to convert logits to (normalized) probabilities
|
| 224 |
# probs = F.softmax(logits, dim=-1)
|
| 225 |
# # sample from the distribution
|
| 226 |
+
log_probs = self(idx_cond, date=date).combined_log_probs[:, -1, :]
|
| 227 |
+
#idx_next = torch.multinomial(probs, num_samples=1)
|
| 228 |
+
# Sample from the log probabilities
|
| 229 |
+
if temperature == 0:
|
| 230 |
+
# If temperature is 0, take the argmax (greedy sampling)
|
| 231 |
+
idx_next = torch.argmax(log_probs, dim=-1, keepdim=True)
|
| 232 |
+
else:
|
| 233 |
+
# Apply temperature scaling
|
| 234 |
+
scaled_log_probs = log_probs / temperature
|
| 235 |
+
# Convert log probabilities to probabilities
|
| 236 |
+
probs = torch.exp(scaled_log_probs)
|
| 237 |
+
# Sample from the distribution
|
| 238 |
+
idx_next = torch.multinomial(probs, num_samples=1)
|
| 239 |
# append sampled index to the running sequence and continue
|
| 240 |
idx = torch.cat((idx, idx_next), dim=1)
|
| 241 |
# check if we hit the end of the sequence
|