Text Generation
PEFT
Safetensors
GGUF
English
materialsanalyst-ai-7b
MaterialsAnalyst-AI-7B
materials-science
computational-materials
materials-analysis
chain-of-thought
reasoning-model
property-prediction
materials-discovery
crystal-structure
materials-informatics
scientific-ai
7b
quantized
fine-tuned
lora
json-mode
structured-output
materials-engineering
band-gap-prediction
computational-chemistry
materials-characterization
Instructions to use Raymond-dev-546730/MaterialsAnalyst-AI-7B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use Raymond-dev-546730/MaterialsAnalyst-AI-7B with PEFT:
Task type is invalid.
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use Raymond-dev-546730/MaterialsAnalyst-AI-7B 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 Raymond-dev-546730/MaterialsAnalyst-AI-7B:Q4_K_M # Run inference directly in the terminal: llama cli -hf Raymond-dev-546730/MaterialsAnalyst-AI-7B:Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf Raymond-dev-546730/MaterialsAnalyst-AI-7B:Q4_K_M # Run inference directly in the terminal: llama cli -hf Raymond-dev-546730/MaterialsAnalyst-AI-7B:Q4_K_M
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf Raymond-dev-546730/MaterialsAnalyst-AI-7B:Q4_K_M # Run inference directly in the terminal: ./llama-cli -hf Raymond-dev-546730/MaterialsAnalyst-AI-7B:Q4_K_M
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf Raymond-dev-546730/MaterialsAnalyst-AI-7B:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama-cli -hf Raymond-dev-546730/MaterialsAnalyst-AI-7B:Q4_K_M
Use Docker
docker model run hf.co/Raymond-dev-546730/MaterialsAnalyst-AI-7B:Q4_K_M
- LM Studio
- Jan
- vLLM
How to use Raymond-dev-546730/MaterialsAnalyst-AI-7B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Raymond-dev-546730/MaterialsAnalyst-AI-7B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Raymond-dev-546730/MaterialsAnalyst-AI-7B", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/Raymond-dev-546730/MaterialsAnalyst-AI-7B:Q4_K_M
- Ollama
How to use Raymond-dev-546730/MaterialsAnalyst-AI-7B with Ollama:
ollama run hf.co/Raymond-dev-546730/MaterialsAnalyst-AI-7B:Q4_K_M
- Unsloth Desktop
- Docker Model Runner
How to use Raymond-dev-546730/MaterialsAnalyst-AI-7B with Docker Model Runner:
docker model run hf.co/Raymond-dev-546730/MaterialsAnalyst-AI-7B:Q4_K_M
- Lemonade
How to use Raymond-dev-546730/MaterialsAnalyst-AI-7B with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull Raymond-dev-546730/MaterialsAnalyst-AI-7B:Q4_K_M
Run and chat with the model
lemonade run user.MaterialsAnalyst-AI-7B-Q4_K_M
List all available models
lemonade list
- Atomic Chat
Upload 2 files
Browse files
Scripts/Inference_llama.cpp.py
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from llama_cpp import Llama
|
| 2 |
+
|
| 3 |
+
# INSTRUCTIONS: Replace the JSON below with your material's properties
|
| 4 |
+
# Common data sources: materialsproject.org, DFT calculations, experimental databases
|
| 5 |
+
|
| 6 |
+
JSON_INPUT = """
|
| 7 |
+
{
|
| 8 |
+
"material_id": "mp-8062",
|
| 9 |
+
"formula": "SiC",
|
| 10 |
+
"elements": [
|
| 11 |
+
"Si",
|
| 12 |
+
"C"
|
| 13 |
+
],
|
| 14 |
+
"spacegroup": "P63mc",
|
| 15 |
+
"band_gap": 3.26,
|
| 16 |
+
"formation_energy_per_atom": -0.73,
|
| 17 |
+
"density": 3.21,
|
| 18 |
+
"volume": 41.2,
|
| 19 |
+
"nsites": 8,
|
| 20 |
+
"is_stable": true,
|
| 21 |
+
"elastic_modulus": 448,
|
| 22 |
+
"bulk_modulus": 220,
|
| 23 |
+
"thermal_expansion": 4.2e-06,
|
| 24 |
+
"electron_affinity": 4.0,
|
| 25 |
+
"ionization_energy": 6.7,
|
| 26 |
+
"crystal_system": "Hexagonal",
|
| 27 |
+
"magnetic_property": "Non-magnetic",
|
| 28 |
+
"thermal_conductivity": 490,
|
| 29 |
+
"specific_heat": 0.69,
|
| 30 |
+
"is_superconductor": false,
|
| 31 |
+
"band_gap_type": "Indirect"
|
| 32 |
+
}
|
| 33 |
+
"""
|
| 34 |
+
|
| 35 |
+
model_path = "./" # Path to the directory containing your model weight files
|
| 36 |
+
|
| 37 |
+
llm = Llama(
|
| 38 |
+
model_path=model_path,
|
| 39 |
+
n_gpu_layers=29,
|
| 40 |
+
n_ctx=10000,
|
| 41 |
+
n_threads=4
|
| 42 |
+
)
|
| 43 |
+
|
| 44 |
+
topic = JSON_INPUT.strip()
|
| 45 |
+
prompt = f"USER: {topic}\nASSISTANT:"
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
output = llm(
|
| 49 |
+
prompt,
|
| 50 |
+
max_tokens=3000,
|
| 51 |
+
temperature=0.7,
|
| 52 |
+
top_p=0.9,
|
| 53 |
+
repeat_penalty=1.1
|
| 54 |
+
)
|
| 55 |
+
|
| 56 |
+
result = output.get("choices", [{}])[0].get("text", "").strip()
|
| 57 |
+
|
| 58 |
+
print(result)
|
| 59 |
+
|
| 60 |
+
|
Scripts/Inference_safetensors.py
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 3 |
+
|
| 4 |
+
# INSTRUCTIONS: Replace the JSON below with your material's properties
|
| 5 |
+
# Common data sources: materialsproject.org, DFT calculations, experimental databases
|
| 6 |
+
|
| 7 |
+
JSON_INPUT = """
|
| 8 |
+
{
|
| 9 |
+
"material_id": "mp-8062",
|
| 10 |
+
"formula": "SiC",
|
| 11 |
+
"elements": [
|
| 12 |
+
"Si",
|
| 13 |
+
"C"
|
| 14 |
+
],
|
| 15 |
+
"spacegroup": "P63mc",
|
| 16 |
+
"band_gap": 3.26,
|
| 17 |
+
"formation_energy_per_atom": -0.73,
|
| 18 |
+
"density": 3.21,
|
| 19 |
+
"volume": 41.2,
|
| 20 |
+
"nsites": 8,
|
| 21 |
+
"is_stable": true,
|
| 22 |
+
"elastic_modulus": 448,
|
| 23 |
+
"bulk_modulus": 220,
|
| 24 |
+
"thermal_expansion": 4.2e-06,
|
| 25 |
+
"electron_affinity": 4.0,
|
| 26 |
+
"ionization_energy": 6.7,
|
| 27 |
+
"crystal_system": "Hexagonal",
|
| 28 |
+
"magnetic_property": "Non-magnetic",
|
| 29 |
+
"thermal_conductivity": 490,
|
| 30 |
+
"specific_heat": 0.69,
|
| 31 |
+
"is_superconductor": false,
|
| 32 |
+
"band_gap_type": "Indirect"
|
| 33 |
+
}
|
| 34 |
+
"""
|
| 35 |
+
|
| 36 |
+
def load_model(model_path):
|
| 37 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 38 |
+
model_path,
|
| 39 |
+
torch_dtype=torch.float16,
|
| 40 |
+
device_map="auto",
|
| 41 |
+
trust_remote_code=True
|
| 42 |
+
)
|
| 43 |
+
|
| 44 |
+
tokenizer = AutoTokenizer.from_pretrained(
|
| 45 |
+
model_path,
|
| 46 |
+
trust_remote_code=True
|
| 47 |
+
)
|
| 48 |
+
|
| 49 |
+
return model, tokenizer
|
| 50 |
+
|
| 51 |
+
def generate_response(model, tokenizer, topic):
|
| 52 |
+
topic = topic.strip()
|
| 53 |
+
|
| 54 |
+
prompt = f"USER: {topic}\nASSISTANT:"
|
| 55 |
+
|
| 56 |
+
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
|
| 57 |
+
|
| 58 |
+
outputs = model.generate(
|
| 59 |
+
**inputs,
|
| 60 |
+
max_new_tokens=3000,
|
| 61 |
+
temperature=0.7,
|
| 62 |
+
top_p=0.9,
|
| 63 |
+
repetition_penalty=1.1,
|
| 64 |
+
do_sample=True
|
| 65 |
+
)
|
| 66 |
+
|
| 67 |
+
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 68 |
+
|
| 69 |
+
return response.split("ASSISTANT:")[-1].strip()
|
| 70 |
+
|
| 71 |
+
def run():
|
| 72 |
+
model_path = "./" # Path to the directory containing your model weight files
|
| 73 |
+
|
| 74 |
+
model, tokenizer = load_model(model_path)
|
| 75 |
+
|
| 76 |
+
result = generate_response(model, tokenizer, JSON_INPUT)
|
| 77 |
+
|
| 78 |
+
print(result)
|
| 79 |
+
|
| 80 |
+
if __name__ == "__main__":
|
| 81 |
+
run()
|
| 82 |
+
|
| 83 |
+
|