LPM-24
Collection
Artifacts Related to the Language + Molecules workshop at ACL 2024 • 12 items • Updated
How to use language-plus-molecules/Meditron7b-caption2smiles-LPM24 with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="language-plus-molecules/Meditron7b-caption2smiles-LPM24") # Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("language-plus-molecules/Meditron7b-caption2smiles-LPM24")
model = AutoModelForCausalLM.from_pretrained("language-plus-molecules/Meditron7b-caption2smiles-LPM24")How to use language-plus-molecules/Meditron7b-caption2smiles-LPM24 with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "language-plus-molecules/Meditron7b-caption2smiles-LPM24"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "language-plus-molecules/Meditron7b-caption2smiles-LPM24",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'docker model run hf.co/language-plus-molecules/Meditron7b-caption2smiles-LPM24
How to use language-plus-molecules/Meditron7b-caption2smiles-LPM24 with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "language-plus-molecules/Meditron7b-caption2smiles-LPM24" \
--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": "language-plus-molecules/Meditron7b-caption2smiles-LPM24",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'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 "language-plus-molecules/Meditron7b-caption2smiles-LPM24" \
--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": "language-plus-molecules/Meditron7b-caption2smiles-LPM24",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'How to use language-plus-molecules/Meditron7b-caption2smiles-LPM24 with Docker Model Runner:
docker model run hf.co/language-plus-molecules/Meditron7b-caption2smiles-LPM24
Below is the prompt used for the model:
prompt_template = ("Below is an instruction that describes a task, paired with an input that provides further context. "
"Write a response that appropriately completes the request.\n\n"
"### Instruction:\n"
"You are a researcher. You can come up molecule smile strings based on your existing knowledge. "
"Molecule smile strings are given against the following input. You should be as detailed as possible.\n\n"
"### Input:\nCaption: %s \nIn that caption, could you generate a molecule smile string?\n\n\n### Response:")