Instructions to use robinfaro/molm_log_prob with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use robinfaro/molm_log_prob with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="robinfaro/molm_log_prob", trust_remote_code=True)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("robinfaro/molm_log_prob", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use robinfaro/molm_log_prob with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "robinfaro/molm_log_prob" # 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_log_prob", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/robinfaro/molm_log_prob
- SGLang
How to use robinfaro/molm_log_prob 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_log_prob" \ --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_log_prob", "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_log_prob" \ --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_log_prob", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use robinfaro/molm_log_prob with Docker Model Runner:
docker model run hf.co/robinfaro/molm_log_prob
Adding files from hf_modeling_btm_log_prob_mixing
Browse files- configuration.py +62 -0
configuration.py
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from transformers import PretrainedConfig
|
| 2 |
+
|
| 3 |
+
class MoLMConfig(PretrainedConfig):
|
| 4 |
+
model_type = "MoLM"
|
| 5 |
+
|
| 6 |
+
def __init__(
|
| 7 |
+
self,
|
| 8 |
+
vocab_size=50304,
|
| 9 |
+
n_embd=768,
|
| 10 |
+
n_layer=12,
|
| 11 |
+
n_head=12,
|
| 12 |
+
sequence_length=1024,
|
| 13 |
+
mlp_dim_exp_factor=1.0,
|
| 14 |
+
dropout=0.0,
|
| 15 |
+
bias=False,
|
| 16 |
+
num_experts=6,
|
| 17 |
+
expert_configs=None,
|
| 18 |
+
use_router=False,
|
| 19 |
+
top_k_experts=6,
|
| 20 |
+
architectures=["MoLM"],
|
| 21 |
+
auto_map={
|
| 22 |
+
"AutoConfig": "configuration.MoLMConfig",
|
| 23 |
+
"AutoModelForCausalLM": "modeling.MoLM",
|
| 24 |
+
"AutoTokenizer": "GPT2TokenizerFast"
|
| 25 |
+
},
|
| 26 |
+
**kwargs,
|
| 27 |
+
):
|
| 28 |
+
super().__init__(**kwargs)
|
| 29 |
+
self.vocab_size = vocab_size
|
| 30 |
+
self.n_embd = n_embd
|
| 31 |
+
self.n_layer = n_layer
|
| 32 |
+
self.n_head = n_head
|
| 33 |
+
self.sequence_length = sequence_length
|
| 34 |
+
self.mlp_dim_exp_factor = mlp_dim_exp_factor
|
| 35 |
+
self.dropout = dropout
|
| 36 |
+
self.bias = bias
|
| 37 |
+
self.num_experts = num_experts
|
| 38 |
+
self.expert_configs = expert_configs
|
| 39 |
+
self.use_router = use_router
|
| 40 |
+
self.architectures = architectures
|
| 41 |
+
self.auto_map = auto_map
|
| 42 |
+
self.top_k_experts = top_k_experts
|
| 43 |
+
def to_dict(self):
|
| 44 |
+
config_dict = super().to_dict()
|
| 45 |
+
config_dict.update({
|
| 46 |
+
"vocab_size": self.vocab_size,
|
| 47 |
+
"n_embd": self.n_embd,
|
| 48 |
+
"n_layer": self.n_layer,
|
| 49 |
+
"n_head": self.n_head,
|
| 50 |
+
"sequence_length": self.sequence_length,
|
| 51 |
+
"mlp_dim_exp_factor": self.mlp_dim_exp_factor,
|
| 52 |
+
"dropout": self.dropout,
|
| 53 |
+
"bias": self.bias,
|
| 54 |
+
"num_experts": self.num_experts,
|
| 55 |
+
"expert_configs": [
|
| 56 |
+
expert_config.to_dict() if not isinstance(expert_config, dict) else expert_config
|
| 57 |
+
for expert_config in self.expert_configs
|
| 58 |
+
] if self.expert_configs else None,
|
| 59 |
+
"use_router": self.use_router,
|
| 60 |
+
"top_k_experts": self.top_k_experts,
|
| 61 |
+
})
|
| 62 |
+
return config_dict
|