Brief AI
›

Scikit-llm: 3 Votes to Measure Llama's Confidence

Research·Tom Levy·

Scikit-llm: 3 Votes to Measure Llama's Confidence

Scikit-llm: 3 Votes to Measure Llama's Confidence
Key Takeaways
1Llama 3.1 8B is run with Ollama and linked to scikit-llm.
2The scores correspond to votes collected on 3 classifications per text.
3Calibration is examined on 9 labeled computing requests.
Why it matters : the system provides scores to evaluate before potential human routing, which is not implemented.

With scikit-llm, a device based on Llama 3.1 8B produces confidence scores by repeating the classification of each text three times. A diagram allows for examining the calibration, but no numerical results are provided. The direction of uncertain cases towards a person remains a contemplated use, absent from the presented code.

The test focuses on 9 IT requests

The reliability check is based on 9 pre-labeled requests, divided among hardware, software, and network, referred to in the program as hardware, software, and network. The chosen criterion is frequentist: an announced confidence of 80% must correspond to 80% correct responses. The graph compares average scores to the proportion of positive responses, with a diagonal representing perfect agreement.

The software requests involve a faulty reset link and Excel crashes when opening large files. On the hardware side, there is a screen that won't turn on and a mouse that triggers unintended double clicks. The network examples describe a VPN that disconnects every 5 minutes and an unavailable Wi-Fi connection in room B.

Ambiguous situations also receive a reference category. A failure involving both the screen and VPN is classified under hardware; a stalled cloud synchronization falls under software, despite a possible network interpretation. An IP phone with a dark screen and no dial tone is categorized among hardware issues, with the same network ambiguity.

To plot the curve on this small sample, the program transforms the labels into binary indicators by category, then flattens them with the scores. The calibration_curve function distributes them into 4 uniform intervals. The flattening aims to smooth the plot. The accuracy calculation uses accuracy_score, but no obtained value is communicated.

The classifier transforms repetitions into scores

The mechanism of consistency between responses, or self-consistency, is supported by SelfConsistentLLMClassifier, a class built around ZeroShotGPTClassifier. The latter assigns a category to the text without learning examples. The constructor sets the model used, the available categories, and the number of passages; the class inherits from BaseEstimator and ClassifierMixin, while its own fit method simply returns the object without training.

The evening letterFree · 7 pm

The AI brief the pros read every evening

The 7 best AI stories, the essentials in 5 min. Free.

Included when you join: our pick of the best AI guides & comparisons.

Choose your rhythm

Free · No spam · Unsubscribe in 1 click

At each repetition, the program creates a classifier and provides the categories via fit, without a training text corpus. Their order is randomized, aiming to limit deterministic responses and reveal hesitations in the face of ambiguous formulations. The obtained labels are counted: predict_proba returns in a NumPy array the proportion of votes corresponding to each category.

One passage on the sample represents 27 inferences. The predict method itself calls predict_proba before retaining the category with the maximum score. However, the evaluation program successively calls these methods: the scores intended for the graph and the labels used for the accuracy calculation thus come from distinct passages.

Ollama provides execution without OpenAI model

The chosen environment combines the Llama 3.1 8B model with Ollama, without resorting to a commercial API. The described execution took place on a Google Colab GPU; the procedure recommends the T4, thus avoiding the download of several gigabytes to personal storage. This configuration is presented as free and open source.

The preparation installs Ollama, the Python package scikit-llm, and zstd, deemed necessary for managing models in this notebook environment. The server starts in the background, then the program pauses for 3 seconds. The command ollama pull llama3.1:8b then retrieves the model.

The connection goes through an interface compatible with OpenAI, but no model from that company is solicited. In SKLLMConfig, the key takes the value ollama-local. The configured address is http://localhost:11434/v1/, which designates the Ollama instance.

Human verification remains to be programmed

The intended use is to reserve human intervention for classifications with insufficient confidence, rather than processing them automatically. However, the provided program stops at producing predictions and their graphical evaluation: it defines neither a trigger value nor a mechanism for sending to a person.

Brief AI — AI news in French

The essentials of artificial intelligence news, decoded and explained every day.