SyncAI.news, a Varaisys broadcasting
Named Entity Recognition Using Scikit-LLM
IP

Iván Palomares Carrascosa

· 1 min read

EngineeringKDnuggets

Named Entity Recognition Using Scikit-LLM

Introduction

Structured data extraction from text has plenty of uses in data analysis and myriad applications, including building predictive machine learning models. Named entity recognition (NER) is a clear example of this: it consists of transforming unstructured, messy text into structured data as a result of identifying, extracting, and categorizing relevant information.

NER has been traditionally conducted using traditional natural language processing (NLP) libraries, but these models usually require huge training datasets and arduous fine-tuning to make them learn to recognize custom entities. Thankfully, Scikit-LLM arose to bring large language model (LLM) reasoning capabilities to the table and help build standardized machine learning pipelines in a few simple steps, all on a variety of target tasks beyond just text classification, including custom NER.

Running Named Entity Recognition with Scikit-LLM

This example can be run entirely in a Google Colab notebook. It uses Groq's LLM API to fully rely on free models. A prerequisite is to access the Groq website, register, and generate your own API key. Once generated, carefully copy your API key (you can do this only once) and paste it as a new "Secret" variable in Google Colab — found at the key icon on the left-hand side of Colab. Here, you'll paste your copied API key and name the secret variable GROQ_API_KEY.

After that, we start our notebook by installing Scikit-LLM:

!pip install scikit-llm -q

Now it's time to dive into Python code, and the first stage is to initialize Scikit-LLM configuration. This library is designed using OpenAI API standards, but it lets us override the base URL with the SKLLMConfig.set_gpt_url() method, letting us point to any other compatible provider, such as Groq:

Besides the entities, we also define a small set of example texts related to the tech business domain and closely aligned with our entity dictionary:

Results:

Result:

Original source

This story was published by KDnuggets and written by Iván Palomares Carrascosa. SyncAI.news shows a preview; the complete article is on the publisher's site.

Read the full story on kdnuggets.com

Similar News