nicolay-r/ARElight
Über uns
Granular Viewer of Sentiments Between Entities in Massively Large Documents and Collections of Texts, powered by AREkit
KI und maschinelles LernenGemessener Sternzuwachs
- in 24h
- 0
- in 7 days
- 0
- in 15 days
- 0
- in 1 month
- Verlauf wird gesammelt
Nettoänderungen in überlappenden Zeiträumen, keine Tagessummen. Fehlende Messwerte bleiben leer. Sterne zeigen Interesse, nicht Qualität.
README.md
OriginalARElight 0.26.2
ARElight is an application for a granular view onto sentiments between mentioned named entities in texts. This repository is a part of the ECIR-2024 demo paper: ARElight: Context Sampling of Large Texts for Deep Learning Relation Extraction.
Installation
pip install git+https://github.com/nicolay-r/[email protected]
Install the demo packages and download the providers:
pip install -r demo/dependencies.txt
sh demo/download_providers.sh
🚀 API
Pass in-memory rows to iter_opinions. Each row has an id and a text.
from dotenv import load_dotenv
from arelight.api import iter_opinions
load_dotenv() # API_TOKEN in .env is read by the inference pipeline
iter_opinions = iter_opinions(
rows_iter=[
{"id": "request:0", "text": "Barack Obama met Angela Merkel in Berlin."}
# ... iterator of texts goes here
],
sampling_args={
"terms_per_context": 50,
"docs_limit": 1,
"parser": {
"provider": ("demo/nltk_provider.py", {"language": "english"}),
},
"collection_target_func": lambda data_type: f"./output/test_samples-{data_type.name.lower()}",
},
predict_filepath="./output/test_samples-test.tsv.gz",
# Translate the document text. These kwargs are forwarded to the translator.
translator_args={
"provider": "demo/googletrans_402.py",
"src": "auto",
"dest": "en",
},
# Find named entities to relate.
ner_args={
"provider": ("demo/dp_130.py", {"model": "ner_ontonotes_bert_mult"}),
"obj_filter": lambda s_obj: s_obj.ObjectType in ["ORG", "PERSON", "LOC", "GPE"],
"chunk_limit": 128,
},
# Classify the attitude between those entities.
inference_args={
"provider": ("demo/replicate_104.py", {"model_name": "meta/meta-llama-3-70b-instruct"}),
"settings": {
"schema": [{
"prompt": "Given text: {text_a}TASK: Classify sentiment attitude of [SUBJECT] to [OBJECT]. Reply with a single integer: 0 for neutral, 1 for positive, 2 for negative.",
"out": "response",
}],
},
},
writer_args={
"writer": "tsv",
},
batch_size=1,
)
for opinion in iter_opinions:
print(opinion["source"], opinion["label"], opinion["target"])
CLI
The command-line entry point reads files and uses the same providers.
Infer sentiment attitudes from a text file in English:
python3 -m arelight.run.infer \
--batch-size 10 \
--from-files "<YOUR-FILES-GOES-HERE>" \
--sampling-framework "arekit" \
--sentence-parser "nltk:english" \
--terms-per-context 50 \
--translate-provider "demo/googletrans_402.py" \
--translate-text "auto:en" \
--ner-provider "demo/dp_130.py" \
--ner-model-name "ner_ontonotes_bert_mult" \
--ner-types "ORG|PERSON|LOC|GPE" \
--inference-filename "demo/replicate_104.py" \
--inference-model-name "meta/meta-llama-3-70b-instruct" \
--inference-writer "tsv" \
--log-file "arelight.log.txt" \
-o "output"
Parameters
The complete documentation is available via -h flag:
python3 -m arelight.run.infer -h
Parameters:
sampling-frameworkwe consider onlyarekitframework by default.from-files-- list of filepaths to the related documents.- for the
.csvfiles we consider that each line of the particularcolumnas a separated document.csv-sep-- separator between columns.csv-column-- name of the column in CSV file.
- for the
collection-name-- name of the result files based on sampled documents.terms-per-context-- total amount of words for a single sample.sentence-parser--nltk:englishornltk:russian. This loads demo/nltk_provider.py. In the API the same splitter is aparserprovider, andparsereturns the list of sentences.synonyms-filepath-- text file with listed synonymous entries, grouped by lines. [example].stemmer-- for words lemmatization (optional); we support [PyMystem].- NER parameters:
ner-framework-- type of the framework:deeppavlov-- [DeepPavlov] list of models.transformers-- [Transformers] list of models.
ner-model-name-- model name within utilized NER framework.ner-types-- list of types to be considered for annotation, separated by|.
docs-limit-- the total limit of documents for sampling.- Translation specific parameters
translate-framework-- text translation backend (optional); we support [googletrans]translate-entity-- (optional) source and target language supported by backend, separated by:.translate-text-- (optional) source and target language supported by backend, separated by:.
bulk_chain-- LLM framework, utilized for relations classification) [bulk-chain]API_TOKENin.env-- API key, loaded withpython-dotenvinside the inference pipeline. It is not aninference_argsfield.inference-filename-- Inference implementation filename. Together withinference-model-namethis is the(path, kwargs)model pair. We usereplicate_104.pyfrom nlp-thirdgate by defaultinference-model-name-- Name of the model, passed asmodel_nameinside that pair. For the Replicate provider we use:meta/meta-llama-3-70b-instructinference-writer-- How to save the classified results;tsvwrites a gzipped table.
-o-- output folder for result collections and demo.
Framework parameters mentioned above as well as their related setups might be omitted.
The GUI server for this pipeline lives in ARElight-server.
Powered by
- AREkit [github]
How to cite
Our one and my personal interest is to help you better explore and analyze attitude and relation extraction related tasks with ARElight. A great research is also accompanied with the faithful reference. if you use or extend our work, please cite as follows:
@inproceedings{rusnachenko2024arelight,
title={ARElight: Context Sampling of Large Texts for Deep Learning Relation Extraction},
author={Rusnachenko, Nicolay and Liang, Huizhi and Kolomeets, Maxim and Shi, Lei},
booktitle={European Conference on Information Retrieval},
year={2024},
organization={Springer}
}
Ähnliche Projekte entdecken
Wird geladen…