Instructions to use alexpro100/MathBERT-GGUF with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use alexpro100/MathBERT-GGUF with sentence-transformers:
from sentence_transformers import SentenceTransformer model = SentenceTransformer("alexpro100/MathBERT-GGUF") sentences = [ "The weather is lovely today.", "It's so sunny outside!", "He drove to the stadium." ] embeddings = model.encode(sentences) similarities = model.similarity(embeddings, embeddings) print(similarities.shape) # [3, 3] - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use alexpro100/MathBERT-GGUF 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 alexpro100/MathBERT-GGUF:F16 # Run inference directly in the terminal: llama cli -hf alexpro100/MathBERT-GGUF:F16
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf alexpro100/MathBERT-GGUF:F16 # Run inference directly in the terminal: llama cli -hf alexpro100/MathBERT-GGUF:F16
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 alexpro100/MathBERT-GGUF:F16 # Run inference directly in the terminal: ./llama-cli -hf alexpro100/MathBERT-GGUF:F16
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 alexpro100/MathBERT-GGUF:F16 # Run inference directly in the terminal: ./build/bin/llama-cli -hf alexpro100/MathBERT-GGUF:F16
Use Docker
docker model run hf.co/alexpro100/MathBERT-GGUF:F16
- LM Studio
- Jan
- Ollama
How to use alexpro100/MathBERT-GGUF with Ollama:
ollama run hf.co/alexpro100/MathBERT-GGUF:F16
- Unsloth Desktop
- Docker Model Runner
How to use alexpro100/MathBERT-GGUF with Docker Model Runner:
docker model run hf.co/alexpro100/MathBERT-GGUF:F16
- Lemonade
How to use alexpro100/MathBERT-GGUF with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull alexpro100/MathBERT-GGUF:F16
Run and chat with the model
lemonade run user.MathBERT-GGUF-F16
List all available models
lemonade list
- Atomic Chat
Description
This model was converted to GGUF format from tbs17/MathBERT using llama.cpp.
For more information go to here.
Test:
import numpy as np
from sentence_transformers import SentenceTransformer
from sentence_transformers.util import cos_sim
import openai
# ./llama.cpp/build/bin/llama-server --models-dir MathBERT-GGUF/ --embeddings
openai_client = openai.OpenAI(
base_url="http://127.0.0.1:8080/v1",
api_key="sk-no-key-required",
)
# embedding get
def get_embedding(text: str, limit_tokens: int=2048, model="embedding") -> list[float]:
response = openai_client.embeddings.create(
input=text[:limit_tokens],
model=model,
)
return response.data[0].embedding
model = SentenceTransformer(
"tbs17/MathBERT",
)
text = """This is text for math. It contains some math formulas, such as $E=mc^2$ and $\\int_0^\\infty e^{-x} dx = 1$."""
embed1 = model.encode(text)
for quant in ["Q8_0", "F16", "F32"]:
embed2 = np.array(get_embedding(text, model=f"MathBERT-0.1B-{quant}"), dtype=np.float32)
print(f"Cosine Similarity with {quant}: {cos_sim(embed1, embed2).item()}")
Output:
Cosine Similarity with Q8_0: 0.9999127984046936
Cosine Similarity with F16: 0.9999980926513672
Cosine Similarity with F32: 0.9999997019767761
Converting
To get the GGUF file, you have to:
- Add file
MathBERT/1_Pooling/config.json:
{"word_embedding_dimension":768,"pooling_mode":"mean","pooling_mode_cls_token":false,"pooling_mode_mean_tokens":true,"pooling_mode_max_tokens":false,"pooling_mode_mean_sqrt_len_tokens":false}
- Add file 'MathBERT/modules.json':
[
{
"idx": 0,
"name": "0",
"path": "",
"type": "sentence_transformers.models.Transformer"
},
{
"idx": 1,
"name": "1",
"path": "1_Pooling",
"type": "sentence_transformers.models.Pooling"
}
]
- And run
./llama.cpp/convert_hf_to_gguf.py MathBERT --outtype q8_0 --outfile MathBERT-GGUF/MathBERT-0.1B-Q8_0.gguf
./llama.cpp/convert_hf_to_gguf.py MathBERT --outtype f16 --outfile MathBERT-GGUF/MathBERT-0.1B-F16.gguf
./llama.cpp/convert_hf_to_gguf.py MathBERT --outtype f32 --outfile MathBERT-GGUF/MathBERT-0.1B-F32.gguf
- Downloads last month
- 16
Hardware compatibility
Log In to add your hardware
8-bit
16-bit
32-bit
Model tree for alexpro100/MathBERT-GGUF
Base model
tbs17/MathBERT