Views
No views yet
pip install transformers nltk1from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
2import nltk
3nltk.download('punkt')
4
5tokenizer = AutoTokenizer.from_pretrained("nandakishormpai/t5-small-machine-articles-tag-generation")
6model = AutoModelForSeq2SeqLM.from_pretrained("nandakishormpai/t5-small-machine-articles-tag-generation")
7
8article_text = """
9Paige, AI in pathology and genomics
10
11Fundamentally transforming the diagnosis and treatment of cancer
12Paige has raised $25M in total. We talked with Leo Grady, its CEO.
13How would you describe Paige in a single tweet?
14AI in pathology and genomics will fundamentally transform the diagnosis and treatment of cancer.
15How did it all start and why?
16Paige was founded out of Memorial Sloan Kettering to bring technology that was developed there to doctors and patients worldwide. For over a decade, Thomas Fuchs and his colleagues have developed a new, powerful technology for pathology. This technology can improve cancer diagnostics, driving better patient care at lower cost. Paige is building clinical products from this technology and extending the technology to the development of new biomarkers for the biopharma industry.
17What have you achieved so far?
18TEAM: In the past year and a half, Paige has built a team with members experienced in AI, entrepreneurship, design and commercialization of clinical software.
19PRODUCT: We have achieved FDA breakthrough designation for the first product we plan to launch, a testament to the impact our technology will have in this market.
20CUSTOMERS: None yet, as we are working on CE and FDA regulatory clearances. We are working with several biopharma companies.
21What do you plan to achieve in the next 2 or 3 years?
22Commercialization of multiple clinical products for pathologists, as well as the development of novel biomarkers that can help speed up and better inform the diagnosis and treatment selection for patients with cancer.
23"""
24
25inputs = tokenizer([article_text], max_length=1024, truncation=True, return_tensors="pt")
26output = model.generate(**inputs, num_beams=8, do_sample=True, min_length=10,
27 max_length=128)
28
29decoded_output = tokenizer.batch_decode(output, skip_special_tokens=True)[0]
30
31tags = [ tag.strip() for tag in decoded_output.split(",")]
32
33print(tags)
34
35# ['Paige', 'AI in pathology and genomics', 'AI in pathology', 'genomics']
36