Today I spent some time working with hf-llm.rs, a Rust library for interacting with Hugging Face models. Even though it’s still in early development, I found it surprisingly easy to get started, and things worked really well. The setup was smooth, and running the models didn’t require much effort.

One thing to note is that some models require a Hugging Face Pro subscription. When I encountered this, I decided to switch to using the model google/gemma-1.1-7b-it, which worked just as nicely for my case without needing a subscription. It’s definitely worth keeping an eye on this project as it evolves.

Some example outputs:

➜  hf-llm.rs git:(main) cargo run --release -- -m "google/gemma-1.1-7b-it" -c
    Finished `release` profile [optimized] target(s) in 0.43s
     Running `target/release/hf-llm -m google/gemma-1.1-7b-it -c`
Starting chat mode. Type 'exit' to end the conversation.
You: Write a Python function that prints the numbers from 1 to 100, but for multiples of 3, print "Fizz" instead of the number, and for multiples of 5, print "Buzz". For numbers that are multiples of both 3 and 5, print "FizzBuzz".
def fizzbuzz(limit):
    for i in range(1, limit + 1):
        if i % 3 == 0 and i % 5 == 0:
            print("FizzBuzz")
        elif i % 3 == 0:
            print("Fizz")
        elif i % 5 == 0:
            print("Buzz")
        else:
            print(i)

Example Usage:

fizzbuzz(100)

Output:

1
2
Fizz
4
Buzz
Fizz
7
8
Fizz
Buzz
11
Fizz
...

Explanation:

While working with this, I also learned some Rust fundamentals that were new to me:

These are the basics I picked up while working with hf-llm.rs and learning Rust. If you’ve used Python extensively, you’ll find that Rust has some similarities, but it’s powerful and efficient in its own way.