Instructions to use lastmass/llama3.1-Medical-Assistant with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use lastmass/llama3.1-Medical-Assistant with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="lastmass/llama3.1-Medical-Assistant") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("lastmass/llama3.1-Medical-Assistant", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use lastmass/llama3.1-Medical-Assistant with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf lastmass/llama3.1-Medical-Assistant:Q4_K_M # Run inference directly in the terminal: llama cli -hf lastmass/llama3.1-Medical-Assistant:Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf lastmass/llama3.1-Medical-Assistant:Q4_K_M # Run inference directly in the terminal: llama cli -hf lastmass/llama3.1-Medical-Assistant:Q4_K_M
Build from source code
git clone https://github.com/ggml-org/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-app # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama serve -hf lastmass/llama3.1-Medical-Assistant:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama cli -hf lastmass/llama3.1-Medical-Assistant:Q4_K_M
Use Docker
docker model run hf.co/lastmass/llama3.1-Medical-Assistant:Q4_K_M
- Llama new
- LM Studio
- Jan
- vLLM
How to use lastmass/llama3.1-Medical-Assistant with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "lastmass/llama3.1-Medical-Assistant" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "lastmass/llama3.1-Medical-Assistant", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/lastmass/llama3.1-Medical-Assistant:Q4_K_M
- SGLang
How to use lastmass/llama3.1-Medical-Assistant 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 "lastmass/llama3.1-Medical-Assistant" \ --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": "lastmass/llama3.1-Medical-Assistant", "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 "lastmass/llama3.1-Medical-Assistant" \ --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": "lastmass/llama3.1-Medical-Assistant", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Ollama
How to use lastmass/llama3.1-Medical-Assistant with Ollama:
ollama run hf.co/lastmass/llama3.1-Medical-Assistant:Q4_K_M
- Unsloth Desktop
- Pi
How to use lastmass/llama3.1-Medical-Assistant with Pi:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf lastmass/llama3.1-Medical-Assistant:Q4_K_M
Configure the model in Pi
# Install Pi: npm install -g @earendil-works/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "llama-cpp": { "baseUrl": "http://localhost:9931/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "lastmass/llama3.1-Medical-Assistant:Q4_K_M" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Docker Model Runner
How to use lastmass/llama3.1-Medical-Assistant with Docker Model Runner:
docker model run hf.co/lastmass/llama3.1-Medical-Assistant:Q4_K_M
- Lemonade
How to use lastmass/llama3.1-Medical-Assistant with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull lastmass/llama3.1-Medical-Assistant:Q4_K_M
Run and chat with the model
lemonade run user.llama3.1-Medical-Assistant-Q4_K_M
List all available models
lemonade list
- Hermes Agent
How to use lastmass/llama3.1-Medical-Assistant with Hermes Agent:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf lastmass/llama3.1-Medical-Assistant:Q4_K_M
Configure Hermes
# Install Hermes: curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash hermes setup # Point Hermes at the local server: hermes config set model.provider custom hermes config set model.base_url http://127.0.0.1:9931/v1 hermes config set model.default lastmass/llama3.1-Medical-Assistant:Q4_K_M
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use lastmass/llama3.1-Medical-Assistant with OpenClaw:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf lastmass/llama3.1-Medical-Assistant:Q4_K_M
Configure OpenClaw
# Install OpenClaw: npm install -g openclaw@latest # Register the local server and set it as the default model: openclaw onboard --non-interactive --mode local \ --auth-choice custom-api-key \ --custom-base-url http://127.0.0.1:9931/v1 \ --custom-model-id "lastmass/llama3.1-Medical-Assistant:Q4_K_M" \ --custom-provider-id llama-cpp \ --custom-compatibility openai \ --custom-text-input \ --accept-risk \ --skip-health
Run OpenClaw
openclaw agent --local --agent main --message "Hello from Hugging Face"
ๅบไบ Meta-Llama-3.1-8B-Instruct ็ไธญๆๅป็ๅฏน่ฏๆจกๅ
ๆฌๆจกๅ้่ฟๅจ meta-llama/Llama-3.1-8B ๅบ็กๆจกๅไธ๏ผไฝฟ็จ Flmc/DISC-Med-SFT ๆฐๆฎ้่ฟ่ก็็ฃๅพฎ่ฐ๏ผSFT๏ผๅพๅฐใ่ฏฅๆจกๅๆจๅจไธบ็จๆทๆไพๅป็็ธๅ
ณ็ๅฏน่ฏๆฏๆใ
ไฝฟ็จGRPO่ฎญ็ป็ๅป็ๆจ็ๆจกๅ็่ฟ้[https://huggingface.co/lastmass/Qwen3_Medical_GRPO]
ๆจกๅๆถๆ
ๆฌๆจกๅ้็จไบ LoRA (Low-Rank Adaptation) ๆๆฏ๏ผ่ฎญ็ปๅ็ LoRA ้้
ๅจๆ้ไฟๅญๅจ adapter_model.safetensors ๆไปถไธญใ
ไฝฟ็จๆนๆณ
1. ไฝฟ็จ peft (ไธๅปบ่ฎฎ๏ผUnsloth ๆด้ซๆ):
from peft import AutoPeftModelForCausalLM
from transformers import AutoTokenizer
model = AutoPeftModelForCausalLM.from_pretrained(
"lora_model", # ๆจ็ๆจกๅ่ทฏๅพ
load_in_4bit = load_in_4bit,
)
tokenizer = AutoTokenizer.from_pretrained("lora_model")
2. ๆจ่ไฝฟ็จ Unsloth ๅบ:
from unsloth import FastLanguageModel
model, tokenizer = FastLanguageModel.from_pretrained(
model_name = "lora_model", # ๆจ็ๆจกๅ่ทฏๅพ
max_seq_length = max_seq_length,
dtype = dtype,
load_in_4bit = load_in_4bit,
)
FastLanguageModel.for_inference(model) # ๅฏ็จๅ็ 2 ๅๅ ้ๆจ็
messages = [
{"role": "user", "content": "ๅคงๅคซ๏ผ่ฏท้ฎๆๆ่ฟ่ๆค้ ่ฟ่
ฐ้จ็ๅฐๆน็ปๅธธๆ็ผ็ๆ๏ผ่ฏท้ฎๆฏไปไนๅๅ ๏ผ"},
{"role":"assistant","content":"ๆจๅฅฝ๏ผๆ นๆฎๆจ็็็ถๆ่ฟฐ๏ผๆๆ็ๆจๅฏ่ฝๆฃๆ่
ฐๆค้ด็็ชๅบ็ใ่ฟไธช็็ถๅธธ่งไบไธญ่ๅนดไบบ๏ผ็ฑไบๆค้ด็ๆไผคๆ้่กๆงๅๅผ่ตทใๆ นๆฎๆ็็ป้ช๏ผๆจๅฏไปฅ่่่ฟ่กMRIๆฃๆฅๆฅ็กฎ่ฎค่ฏๆญใ'"},
{"role": "user", "content": "ๅคงๅคซ๏ผๆๆฏๅคฉ้่ฆๅๅพไน
๏ผๆฏไธๆฏไนๅ่ฟไธชๆๅ
ณ็ณป๏ผไฟๆๆๆ ท็ๅๅงฟไผๆนๅๅข๏ผ"},
]
inputs = tokenizer.apply_chat_template(
messages,
tokenize = True,
add_generation_prompt = True, # ๅฟ
้กปๆทปๅ ไปฅ็จไบ็ๆ
return_tensors = "pt",
).to("cuda")
from transformers import TextStreamer
text_streamer = TextStreamer(tokenizer, skip_prompt = True)
_ = model.generate(input_ids = inputs, streamer = text_streamer, max_new_tokens = 128,
use_cache = True, temperature = 1.5, min_p = 0.1)
3. ไฝฟ็จ unsloth.Q4_K_M.gguf (็จไบ ollama ๅ llama.cpp):
ๅฐ unsloth.Q4_K_M.gguf ไธไปฅไธ Modelfile ๆพ็ฝฎๅจๅไธ็ฎๅฝ๏ผ
from unsloth.Q4_K_M.gguf
SYSTEM "ไฝ ๆฏไธๅไธไธ็ๅ
จ็งๅป็๏ผๅ็ญ็่ฏญๆฐๅฟ
้กปไธไธ่ไบฒๅ๏ผ้่ฆๆ นๆฎๆฃ่
ๆๅบ็็็ถๆ่ฟฐๆฅๅ็ญ้ฎ้ข,ๆธ
ๆฐไธไธ็ๅ็ญๆฃ่
ๆๅบ็้ฎ้ขใ"
TEMPLATE """{{ if .Messages }}
{{- if or .System .Tools }}<|start_header_id|>system<|end_header_id|>
{{- if .System }}
{{ .System }}
{{- end }}
{{- if .Tools }}
You are a helpful assistant with tool calling capabilities. When you receive a tool call response, use the output to format an answer to the original use question.
{{- end }}
{{- end }}<|eot_id|>
{{- range $i, $_ := .Messages }}
{{- $last := eq (len (slice $.Messages $i)) 1 }}
{{- if eq .Role "user" }}<|start_header_id|>user<|end_header_id|>
{{- if and $.Tools $last }}
Given the following functions, please respond with a JSON for a function call with its proper arguments that best answers the given prompt.
Respond in the format {"name": function name, "parameters": dictionary of argument name and its value}. Do not use variables.
{{ $.Tools }}
{{- end }}
{{ .Content }}<|eot_id|>{{ if $last }}<|start_header_id|>assistant<|end_header_id|>
{{ end }}
{{- else if eq .Role "assistant" }}<|start_header_id|>assistant<|end_header_id|>
{{- if .ToolCalls }}
{{- range .ToolCalls }}{"name": "{{ .Function.Name }}", "parameters": {{ .Function.Arguments }}}{{ end }}
{{- else }}
{{ .Content }}{{ if not $last }}<|eot_id|>{{ end }}
{{- end }}
{{- else if eq .Role "tool" }}<|start_header_id|>ipython<|end_header_id|>
{{ .Content }}<|eot_id|>{{ if $last }}<|start_header_id|>assistant<|end_header_id|>
{{ end }}
{{- end }}
{{- end }}
{{- else }}
{{- if .System }}<|start_header_id|>system<|end_header_id|>
{{ .System }}<|eot_id|>{{ end }}{{ if .Prompt }}<|start_header_id|>user<|end_header_id|>
{{ .Prompt }}<|eot_id|>{{ end }}<|start_header_id|>assistant<|end_header_id|>
{{ end }}{{ .Response }}{{ if .Response }}<|eot_id|>{{ end }}"""
PARAMETER stop "<|start_header_id|>"
PARAMETER stop "<|end_header_id|>"
PARAMETER stop "<|eot_id|>"
PARAMETER stop "<|eom_id|>"
PARAMETER temperature 1.1
PARAMETER min_p 0.1
ๅจๅฎๅtermuxไธญไฝฟ็จ๏ผๆ่ฐขsnippets๏ผhttps://gitlab.com/-/snippets/3682973๏ผ
Ollama on Termux
Install Dependancies
pkg upgrade
pkg install git cmake golang
Build Ollama from source
git clone --depth 1 https://github.com/ollama/ollama.git
cd ollama
go generate ./...
go build .
./ollama serve &
./ollama run lastmass/llama3.2-chinese
Cleanup
You may want to remove the 'go' folder that was just created in your home directory. If so here is how to do it.
chmod -R 700 ~/go
rm -r ~/go
Currently, termux does not have .local/bin in its PATH (though you can add it if you would prefer). If you would like to move the ollama binary to the bin folder you can do the following.
cp ollama/ollama /data/data/com.termux/files/usr/bin/
Now you can just run ollama in your terminal directly!
ๆณจๆไบ้กน
- ๆฌๆจกๅๅบไบๅ ฌๅผๆฐๆฎ้่ฟ่ก่ฎญ็ป๏ผๅฏ่ฝๅญๅจไธๅฎ็ๅๅทฎๆไธๅ็กฎๆงใ
- ๆจกๅ่พๅบ็ๆๆฌไป ไพๅ่๏ผไธ่ฝๆฟไปฃไธไธ็ๅป็ๅปบ่ฎฎๆ่ฏๆญใ
- ่ฏทๅกๅฟ ๅจ่ฏขๅป็ๆๅ ถไปๅป็ไธไธไบบๅฃซไปฅ่ทๅๅ็กฎ็ๅป็ไฟกๆฏๅๆฒป็ๆนๆกใ
- ๅจๅป็ๅบๆฏไธญไฝฟ็จ่ฏฅๆจกๅๆถ๏ผ่ฏทๅกๅฟ ่ฐจๆ ่ฏไผฐๅ ถ่พๅบ๏ผๅนถ็ปๅๅ ถไปๅป็่ตๆบ่ฟ่ก็ปผๅๅคๆญใ
ๅ ่ดฃๅฃฐๆ
ๆฌๆจกๅๆไพ็ๅป็ๅปบ่ฎฎๅไฟกๆฏไป ไธบๅ่๏ผไธๆๆไปปไฝๅฝขๅผ็ๅป็่ฏๆญๆๆฒป็ๅปบ่ฎฎใ่ฏทๅจๅจ่ฏขไธไธๅป็ไบบๅๅ๏ผๅ่ฟ่กไปปไฝๅป็ๅณ็ญใๅฏนไบๅ ไฝฟ็จๆฌๆจกๅๆไบง็็ไปปไฝๅๆ๏ผๆฌๆจกๅๆไพ่ ไธๆฟๆ ไปปไฝ่ดฃไปปใ
- Downloads last month
- 105
4-bit
Model tree for lastmass/llama3.1-Medical-Assistant
Base model
meta-llama/Llama-3.1-8B