This documentation describes the integration of MindsDB with Hugging Face Inference API.
The integration allows for the deployment of Hugging Face models through Inference API within MindsDB, providing the models with access to data from various data sources.
To use Hugging Face Inference API within MindsDB, install the required dependencies following this instruction.
Obtain the API key for Hugging Face Inference API required to deploy and use Hugging Face models through Inference API within MindsDB. Generate tokens in the Settings -> Access Tokens tab of the Hugging Face account.
Create a model using huggingface_api_engine as an engine.
Copy
Ask AI
CREATE MODEL huggingface_api_modelPREDICT target_columnUSING engine = 'huggingface_api_engine', -- engine name as created via CREATE ML_ENGINE task = 'task_name', -- choose one of 'text-classification', 'text-generation', 'question-answering', 'sentence-similarity', 'zero-shot-classification', 'summarization', 'fill-mask', 'image-classification', 'object-detection', 'automatic-speech-recognition', 'audio-classification' input_column = 'column_name', -- column that stores input/question to the model labels = ['label 1', 'label 2']; -- labels used to classify data (used for classification tasks)
The following usage examples utilize huggingface_api_engine to create a model with the CREATE MODEL statement.Create a model to classify input text as spam or ham.
SELECT text, is_spamFROM spam_classifierWHERE text = 'Subscribe to this channel asap';
Here is the output:
Copy
Ask AI
+--------------------------------+---------+| text | is_spam |+--------------------------------+---------+| Subscribe to this channel asap | spam |+--------------------------------+---------+
Next StepsFollow this link to see more use case examples.