Beta API client for Hugging Face Inference API. Directly call any model available in the Model Hub https://huggingface.co/models.
This is a Rust port of the hfapi Python package.
See example inference widget on https://huggingface.co/distilbert-base-uncased.
cargo install --git https://github.com/o-wth/hfapi.rs
extern crate hfapi;
client = hfapi::Client{};
client.question_answering("Where does she live?", "She lives in Berlin.")
{'score': 0.9375529668751711, 'start': 13, 'end': 19, 'answer': 'Berlin.'}
client.text_generation("My name is Julien and I like to ", model="gpt2")
[{'generated_text': "My name is Julien and I like to \xa0play guitar, rock, record record, I can't thi nk of a more unique band, I feel like i'm really connected, I always want to work and im passionate, thi s feels like the"}]
client.summarization("The tower is 324 metres (1,063 ft) tall, about the same height as an 81-storey building, and the tallest structure in Paris. Its base is square, measuring 125 metres (410 ft) on each side. During its construction, the Eiffel Tower surpassed the Washington Monument to become the tallest man-made structure in the world, a title it held for 41 years until the Chrysler Building in New York City was finished in 1930. It was the first structure to reach a height of 300 metres. Due to the addition of a broadcasting aerial at the top of the tower in 1957, it is now taller than the Chrysler Building by 5.2 metres (17 ft). Excluding transmitters, the Eiffel Tower is the second tallest free-standing structure in France after the Millau Viaduct.")
[{'summary_text': ' The Eiffel Tower in Paris has officially opened its doors to the public.'}]
client.fill_mask("Paris is the [MASK] of France."))
[{'sequence': '[CLS] paris is the capital of france. [SEP]', 'score': 0.9815465807914734, 'token': 3007, 'token_str': 'capital'}, {'sequence': '[CLS] paris is the birthplace of france. [SEP]', 'score': 0.00334245921112597, 'token': 14508, 'token_str': 'birthplace'}, {'sequence': '[CLS] paris is the northernmost of france. [SEP]', 'score': 0.001044721808284521, 'token': 22037, 'token_str': 'northernmost'}, {'sequence': '[CLS] paris is the centre of france. [SEP]', 'score': 0.001004318823106587, 'token': 2803, 'token_str': 'centre'}, {'sequence': '[CLS] paris is the southernmost of france. [SEP]', 'score': 0.0007803254993632436, 'token': 21787, 'token_str': 'southernmost'}]
client.text_classification("I hated the movie!")
[[{'label': 'NEGATIVE', 'score': 0.9996837973594666}, {'label': 'POSITIVE', 'score': 0.0003162133798468858}]]
client.token_classification("My name is Sarah and I live in London")
[{'entity_group': 'B-PER', 'score': 0.9985478520393372, 'word': 'Sarah'}, {'entity_group': 'B-LOC', 'score': 0.999621570110321, 'word': 'London'}]