import gradio as gr with open('materials/introduction.html', 'r', encoding='utf-8') as file: html_description = file.read() with gr.Blocks() as landing_interface: gr.HTML(html_description) with gr.Accordion("How to run this model locally", open=False): with gr.Accordion("Simple pipelines", open=False): gr.Markdown( """ ## Installation To use this model with UTCA framework or transformers, you must install the UTCA Python library firstly (it includes transformers): With UTCA: ``` pip install utca -U ``` With transformers: ``` pip install transformers ``` ## Usage Once you've downloaded the GLiNER library, you can import the GLiNER class. You can then load this model using `GLiNER.from_pretrained` and predict entities with `predict_entities`. """ ) gr.Code( ''' from transformers import AutoTokenizer, AutoModelForTokenClassification, pipeline from utca.implementation.predictors.token_searcher.token_searcher_pipeline import TokenClassificationPipeline def process(text, prompt, treshold=0.5): """ Processes text by preparing prompt and adjusting indices. Args: text (str): The text to process prompt (str): The prompt to prepend to the text Returns: list: A list of dicts with adjusted spans and scores """ # Concatenate text and prompt for full input input_ = f"{prompt}\n{text}" results = nlp(input_) # Run NLP on full input processed_results = [] prompt_length = len(prompt) # Get prompt length for result in results: # check whether score is higher than treshold if result['score']