
# REBEL-ru
Based on russian part of wikipedia (scrapped with CROCODILE). 
Model trained for 3 epochs on russian ruT5-base


# How to use
Same code as REBEL-large (https://huggingface.co/Babelscape/rebel-large)
```

text = '''За последние 9 месяцев инвесторы в азиатские долларовые долговые обязательства потеряли 155 миллиардов долларов, пострадав от слабости Китая в дополнение к глобальной распродаже фиксированного дохода, наблюдаемой во всем мире по мере роста процентных ставок. '''


model_path = r"memyprokotow/rut5-REBEL-base"
triplet_extractor = pipeline('text2text-generation', model=model_path, 
                             tokenizer=model_path,
                             #device=0
                             )
# We need to use the tokenizer manually since we need special tokens.
extracted_text = triplet_extractor.tokenizer.batch_decode([triplet_extractor(text, return_tensors=True, return_text=False, max_length=500)[0]["generated_token_ids"]])

print(extracted_text[0])
# Function to parse the generated text and extract the triplets
def extract_triplets(text):
    triplets = []
    relation, subject, relation, object_ = '', '', '', ''
    text = text.strip()
    current = 'x'
    for token in text.replace("<s>", "").replace("<pad>", "").replace("</s>", "").split():
        if token == "<triplet>":
            current = 't'
            if relation != '':
                triplets.append({'head': subject.strip(), 'type': relation.strip(),'tail': object_.strip()})
                relation = ''
            subject = ''
        elif token == "<subj>":
            current = 's'
            if relation != '':
                triplets.append({'head': subject.strip(), 'type': relation.strip(),'tail': object_.strip()})
            object_ = ''
        elif token == "<obj>":
            current = 'o'
            relation = ''
        else:
            if current == 't':
                subject += ' ' + token
            elif current == 's':
                object_ += ' ' + token
            elif current == 'o':
                relation += ' ' + token
    if subject != '' and relation != '' and object_ != '':
        triplets.append({'head': subject.strip(), 'type': relation.strip(),'tail': object_.strip()})
    return triplets
extracted_triplets = extract_triplets(extracted_text[0])
print(extracted_triplets)
```

{"language": ["ru"], "license": "apache-2.0", "tags": ["seq2seq", "relation-extraction", "t5"], "datasets": ["memyprokotow/rebel-dataset-rus"], "widget": [{"text": "\u0417\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0435 9 \u043c\u0435\u0441\u044f\u0446\u0435\u0432 \u0438\u043d\u0432\u0435\u0441\u0442\u043e\u0440\u044b \u0432 \u0430\u0437\u0438\u0430\u0442\u0441\u043a\u0438\u0435 \u0434\u043e\u043b\u043b\u0430\u0440\u043e\u0432\u044b\u0435 \u0434\u043e\u043b\u0433\u043e\u0432\u044b\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u0430 \u043f\u043e\u0442\u0435\u0440\u044f\u043b\u0438 155 \u043c\u0438\u043b\u043b\u0438\u0430\u0440\u0434\u043e\u0432 \u0434\u043e\u043b\u043b\u0430\u0440\u043e\u0432, \u043f\u043e\u0441\u0442\u0440\u0430\u0434\u0430\u0432 \u043e\u0442 \u0441\u043b\u0430\u0431\u043e\u0441\u0442\u0438 \u041a\u0438\u0442\u0430\u044f \u0432 \u0434\u043e\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043a \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u043e\u0439 \u0440\u0430\u0441\u043f\u0440\u043e\u0434\u0430\u0436\u0435 \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0434\u043e\u0445\u043e\u0434\u0430, \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0435\u043c\u043e\u0439 \u0432\u043e \u0432\u0441\u0435\u043c \u043c\u0438\u0440\u0435 \u043f\u043e \u043c\u0435\u0440\u0435 \u0440\u043e\u0441\u0442\u0430 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043d\u044b\u0445 \u0441\u0442\u0430\u0432\u043e\u043a."}]}
transformers pytorch t5 text2text-generation seq2seq relation-extraction ru dataset:memyprokotow/rebel-dataset-rus license:apache-2.0 autotrain_compatible endpoints_compatible text-generation-inference region:us
TAGS
#transformers #pytorch #t5 #text2text-generation #seq2seq #relation-extraction #ru #dataset-memyprokotow/rebel-dataset-rus #license-apache-2.0 #autotrain_compatible #endpoints_compatible #text-generation-inference #region-us 


# REBEL-ru
Based on russian part of wikipedia (scrapped with CROCODILE). 
Model trained for 3 epochs on russian ruT5-base


# How to use
Same code as REBEL-large (URL


# REBEL-ru
Based on russian part of wikipedia (scrapped with CROCODILE). 
Model trained for 3 epochs on russian ruT5-base # How to use
Same code as REBEL-large (URL
TAGS
#transformers #pytorch #t5 #text2text-generation #seq2seq #relation-extraction #ru #dataset-memyprokotow/rebel-dataset-rus #license-apache-2.0 #autotrain_compatible #endpoints_compatible #text-generation-inference #region-us 
 # REBEL-ru
Based on russian part of wikipedia (scrapped with CROCODILE). 
Model trained for 3 epochs on russian ruT5-base # How to use
Same code as REBEL-large (URL
passage: TAGS
#transformers #pytorch #t5 #text2text-generation #seq2seq #relation-extraction #ru #dataset-memyprokotow/rebel-dataset-rus #license-apache-2.0 #autotrain_compatible #endpoints_compatible #text-generation-inference #region-us 
# REBEL-ru
Based on russian part of wikipedia (scrapped with CROCODILE). 
Model trained for 3 epochs on russian ruT5-base# How to use
Same code as REBEL-large (URL