Downloads · 30 days
0
zelalt/titletor-phi_1-5
titletor-phi_1-5 is a machine learning model from zelalt. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as other.
Downloads · 30 days
0
Access
Public
Updated Jul 3, 2024
Repo size
75.5 MB
Likes
2
Public
Click a slice to open those files.
.safetensors75.5 MB · 95%
From the Hugging Face model README
This model is a fine-tuned version of microsoft/phi-1_5 on zelalt/scientific-papers-3.5-withprompt dataset. It achieves the following results on the evaluation set:
!pip install accelerate transformers einops datasets peft bitsandbytes
If you prefer, you can use test dataset from zelalt/scientific-papers or zelalt/arxiv-papers or read your pdf as text with PyPDF2.PdfReader then give this text to LLM with adding "What is the title of this paper?" prompt.
from datasets import load_dataset
test_dataset = load_dataset("zelalt/scientific-papers", split='train')
test_dataset = test_dataset.rename_column('full_text', 'text')
def formatting(example):
text = f"What is the title of this paper? {example['text'][:180]}\n\nAnswer: "
return {'text': text}
formatted_dataset = test_dataset.map(formatting)
import torch
from peft import PeftModel, PeftConfig
from transformers import AutoModelForCausalLM, AutoTokenizer
peft_model_id = "zelalt/titletor-phi_1-5"
config = PeftConfig.from_pretrained(peft_model_id)
model = AutoModelForCausalLM.from_pretrained(config.base_model_name_or_path, trust_remote_code=True)
tokenizer = AutoTokenizer.from_pretrained(config.base_model_name_or_path,trust_remote_code=True)
model = PeftModel.from_pretrained(model, peft_model_id)
#from dataset
inputs = tokenizer(f'''{formatted_dataset['text'][120]}''', return_tensors="pt", return_attention_mask=False)
outputs = model.generate(**inputs,max_new_tokens=50, pad_token_id = tokenizer.eos_token_id, eos_token_id = tokenizer.eos_token_id)
text = tokenizer.batch_decode(outputs)[0]
print(text)
#as string
inputs = tokenizer(f'''What is the title of this paper? ...[your pdf as text]..\n\nAnswer: ''', return_tensors="pt", return_attention_mask=False)
outputs = model.generate(**inputs,max_new_tokens=50, pad_token_id = tokenizer.eos_token_id, eos_token_id = tokenizer.eos_token_id)
text = tokenizer.batch_decode(outputs)[0]
print(text)
Notes
Input:
What is the title of this paper? Bursting Dynamics of the 3D Euler Equations\nin Cylindrical Domains\nFrançois Golse ∗ †\nEcole Polytechnique, CMLS\n91128 Palaiseau Cedex, France\nAlex Mahalov ‡and Basil Nicolaenko §\n\nAnswer:
What is the title of this paper? Bursting Dynamics of the 3D Euler Equations
in Cylindrical Domains
François Golse ∗ †
Ecole Polytechnique, CMLS
91128 Palaiseau Cedex, France
Alex Mahalov ‡and Basil Nicolaenko §
Answer: Bursting Dynamics of the 3D Euler Equations in Cylindrical Domains<|endoftext|>
Train and validation dataset: zelalt/scientific-papers-3.5-withprompt