Skip to main content

LLM plugin providing access to the huggingface inference API

Project description

Hugging Face LLM Plugin

LLM plugin for the HuggingFace Inference API.

Due to the unmanageable number of available models on HuggingFace, listing all of them is unfeasible and impractical, so you will need to manually add the models that you want to use. See instructions below.

Installation

First, install the LLM command-line utility.

Now install this plugin in the same environment as LLM.

llm install llm-huggingface

or, clone this repository and run llm install ..

Configuration

Although the Inference API can supposedly work without one, I haven't tested it, so I recommend you get an API key from HuggingFace. Here are the instructions.

You can set that as an environment variable called LLM_HUGGINGFACE_KEY, or add it to the llm set of saved keys using:

llm keys set huggingface
Enter key: <paste key here>

Usage

To use the plugin, you need to manually add the models you intend to use:

llm hf add <model-id> # for example, llm model hf add bigscience/bloom

You can also llm hf list to list all available models, which should also be listed when running llm models and llm hf rm <model_id> to remove a model you don't want to see in your list anymore.

Once the model is added, use llm normally.

llm -m huggingface/bigscience/bloom "What is AGI? According to"                                                         
What is AGI? According to the definition of the National Institute of Standards and Technology (NIST), AGI is a machine that

Available options are:

  • top_k
  • top_p
  • temperature
  • length: corresponds to the max_new_tokens parameter in the Inference API
llm -m huggingface/bigscience/bloom -o length 100 -o top_k 5 -o top_p 0.8 -o temperature 1.2 "What is AGI? According to"
What is AGI? According to the Wikipedia page, AGI is an artificial general intelligence. That is, an intelligence that can do any task that a human can. The article goes on to describe a few different approaches, but it is clear that no one has yet succeeded at creating a true AGI.
What is an AI? An AI is an artificial intelligence. It is a computer that is designed to think like a human. The AI is designed to do a task, or tasks, that are similar to what a human does

Limitations

This was really just for me to scratch an itch and be able to play with models hosted on HuggingFace from the command line, I love llm and figured I might as well do a little extra work to be able to use it for this. It's not intended to be feature complete and it hasn't been tested much, but I'm happy to add more features if there is interest.

  • Streaming: not supported.
  • Chat Mode: chat mode is untested and will almost certainly not work as expected.
  • Advanced Features: while the plugin currently uses the requests library for API calls, integrating huggingface_hub.InferenceClient could unlock more advanced features in future versions.

Contributing

Contributions to improve the plugin or add new features are welcome! If you encounter any issues or have suggestions for enhancements, please open an issue or submit a pull request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • Thanks to the creator of llm for the amazing CLI and the llm-openrouter plugin which I used as reference. Thanks also to llm-ollama, both for the plugin and the reference.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

llm-huggingface-0.0.1.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

llm_huggingface-0.0.1-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file llm-huggingface-0.0.1.tar.gz.

File metadata

  • Download URL: llm-huggingface-0.0.1.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.10.9

File hashes

Hashes for llm-huggingface-0.0.1.tar.gz
Algorithm Hash digest
SHA256 3cff80486f97daf0eae16e79f430663c159b4410cda6bb1ef7b7554a205b259f
MD5 c1e63dc10bc9934b81870b04cf300293
BLAKE2b-256 43b94a51d7fff98e87a8e37fdef7edea8938c0dfa30732308020f006d44a831b

See more details on using hashes here.

File details

Details for the file llm_huggingface-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for llm_huggingface-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 135691adf90992b5fd2073c57dc5dc8c85a55700ea548767fd37eb2ab76c3bc9
MD5 785c2c43299cf24053650cc6f719b7ed
BLAKE2b-256 1026bbacd479b96ad04aced98bdda0da8ef5e307906888f11b99d7faa6c3fe5b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page