gauneg's picture
Update README.md
27979bb verified
|
raw
history blame
1.04 kB
metadata
language:
  - en
license: apache-2.0
base_model:
  - FacebookAI/roberta-base
pipeline_tag: token-classification

Usage

  • Importing the libraries and loading the models and the pipeline
from transformers import AutoTokenizer, AutoModelForTokenClassification, pipeline
model_id = "gauneg/roberta-base-absa-ate-sentiment"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForTokenClassification.from_pretrained(model_id)

ate_sent_pipeline = pipeline(task='ner', 
                  aggregation_strategy='simple',
                  tokenizer=tokenizer,
                  model=model)


  • Using the pipeline object:
text_input = "Been here a few times and food has always been good but service really suffers when it gets crowded."
ate_sent_pipeline(text_input)
  • pipeline output:
[{'entity_group': 'pos',
  'score': 0.8447307,
  'word': ' food',
  'start': 26,
  'end': 30},
 {'entity_group': 'neg',
  'score': 0.81927896,
  'word': ' service',
  'start': 56,
  'end': 63}]