import argparse
import torch
from openmind import is_torch_npu_available
from openmind import AutoTokenizer, AutoModelForCausalLM
def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument(
"--model_name_or_path",
type=str,
help="Path to model",
default=None,
)
args = parser.parse_args()
return args
def main():
args = parse_args()
if args.model_name_or_path:
model_path = args.model_name_or_path
else:
model_path = "../"
if is_torch_npu_available():
device = "npu:0"
else:
device = "cpu"
file_name = 'SmolLM2-1.7B-Instruct.F16.gguf'
tokenizer = AutoTokenizer.from_pretrained("Rose/SmolLM2-1.7B-Instruct-GGUF",gguf_file=file_name)
model = AutoModelForCausalLM.from_pretrained("Rose/SmolLM2-1.7B-Instruct-GGUF",gguf_file=file_name)
input_ids = tokenizer("Gra", return_tensors='pt').to(model.device)["input_ids"]
output = model.generate(input_ids, max_new_tokens=48, do_sample=True, temperature=0.7)
print(tokenizer.decode(output[0]))
if __name__ == "__main__":
main()| File Name | Size | Quantization Level | Description |
|---|---|---|---|
SmolLM2-1.7B-Instruct.F16.gguf | 3.42GB | FP16 | Full precision 16-bit floats, offering the best accuracy, suitable for high-performance setups. |
SmolLM2-1.7B-Instruct.Q4_K_M.gguf | 1.06GB | Q4 | Quantized to 4-bit, prioritizes memory efficiency and faster inference, with a trade-off in accuracy. |
SmolLM2-1.7B-Instruct.Q5_K_M.gguf | 1.23GB | Q5 | Balanced quantization at 5-bit, offering a compromise between memory use and model accuracy. |
SmolLM2-1.7B-Instruct.Q8_0.gguf | 1.82GB | Q8 | 8-bit quantization, designed for moderate performance with improved accuracy over lower-bit models. |
Ollama is a powerful tool that allows you to run machine learning models effortlessly. This guide will help you download, install, and run your own GGUF models in just a few minutes.
To get started, download Ollama from https://ollama.com/download and install it on your Windows or Mac system.
First, create a model file and name it appropriately. For example, you can name your model file metallama.
In your model file, include a FROM line that specifies the base model file you want to use. For instance:
FROM Llama-3.2-1B.F16.ggufEnsure that the model file is in the same directory as your script.
Open your terminal and run the following command to create and patch your model:
ollama create metallama -f ./metallamaOnce the process is successful, you will see a confirmation message.
To verify that the model was created successfully, you can list all models with:
ollama listMake sure that metallama appears in the list of models.
To run your newly created model, use the following command in your terminal:
ollama run metallamaIn the command prompt, you can execute:
D:\>ollama run metallamaYou can interact with the model like this:
>>> write a mini passage about space x
Space X, the private aerospace company founded by Elon Musk, is revolutionizing the field of space exploration.
With its ambitious goals to make humanity a multi-planetary species and establish a sustainable human presence in
the cosmos, Space X has become a leading player in the industry. The company's spacecraft, like the Falcon 9, have
demonstrated remarkable capabilities, allowing for the transport of crews and cargo into space with unprecedented
efficiency. As technology continues to advance, the possibility of establishing permanent colonies on Mars becomes
increasingly feasible, thanks in part to the success of reusable rockets that can launch multiple times without
sustaining significant damage. The journey towards becoming a multi-planetary species is underway, and Space X
plays a pivotal role in pushing the boundaries of human exploration and settlement.With these simple steps, you can easily download, install, and run your own models using Ollama. Whether you're exploring the capabilities of Llama or building your own custom models, Ollama makes it accessible and efficient.