Views
No views yet
Total Savings: 51.6% smaller than the original version.
TECHNICAL NOTE: On CPUs without native FP16 support, this model may experience a 'tax' resulting in slower tokens-per-second than the original. This model is RAM-optimized, not necessarily CPU-Latency optimized in its raw FP16 state.
bitsandbytes library
in Python.
(pip install bitsandbytes)1from transformers import AutoModelForCausalLM, AutoTokenizer
2import torch
3
4model_id = "Fu01978/SmollerLM2-360M-Instruct-Pruned"
5tokenizer = AutoTokenizer.from_pretrained(model_id)
6
7model = AutoModelForCausalLM.from_pretrained(
8 model_id,
9 torch_dtype=torch.float16,
10 quantization_config={"load_in_8bit": True},
11 device_map="auto"
12)1from transformers import AutoModelForCausalLM, AutoTokenizer
2import torch
3
4model_id = "Fu01978/SmollerLM2-360M-Instruct-Pruned"
5tokenizer = AutoTokenizer.from_pretrained(model_id)
6
7model = AutoModelForCausalLM.from_pretrained(
8 model_id,
9 quantization_config={"load_in_4bit": True},
10 device_map="auto"
11)1# Define your message(s)
2messages = [
3 {"role": "user", "content": "Explain the concept of gravity."}
4]
5
6input_text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
7inputs = tokenizer(input_text, return_tensors="pt").to(model.device)
8
9with torch.no_grad():
10 outputs = model.generate(
11 **inputs,
12 max_new_tokens=150,
13 temperature=0.2,
14 do_sample=True,
15 repetition_penalty=1.1
16 )
17
18response = tokenizer.decode(outputs[0][inputs.input_ids.shape[-1]:], skip_special_tokens=True)
19print(response)Gravity is indeed one of the most fundamental concepts in physics and mathematics. It's essentially the "attraction" between two bodies or masses. According to Einstein's theory of general relativity, mass warps space-time around it, creating a gravitational field that attracts other objects with mass. This means that anything having mass has a gravitational pull on other matter, making them feel heavy. For example, when you drop an object, you're not really feeling its weight; rather, you're feeling the gravitational force exerted by the Earth. The actual weight of an object depends on how massive the object itself is, which can be calculated using formulas like F=G x m/r^2 where G is the gravitational constant, [hit 150 token limit]