Views
No views yet
1from transformers import AutoTokenizer, AutoModelForCausalLM
2import torch
3
4# Set parameters
5model_dir = "rohitanurag/ClinicalGPT-Pubmed-Instruct-V1.0"
6max_new_tokens = 1500
7device = "cuda" if torch.cuda.is_available() else "cpu"
8
9# Load tokenizer and model
10tokenizer = AutoTokenizer.from_pretrained(model_dir)
11model = AutoModelForCausalLM.from_pretrained(model_dir).to(device)
12
13# Define your question
14question = "What is the role of the tumor microenvironment in cancer progression?"
15prompt = f"""Please provide the answer to the question asked.
16### Question: {question}
17### Answer: """
18
19# Tokenize input
20inputs = tokenizer(prompt, return_tensors="pt", padding=True, truncation=True).to(device)
21
22# Generate output
23output_ids = model.generate(
24 inputs.input_ids,
25 attention_mask=inputs.attention_mask,
26 max_new_tokens=1000,
27 repetition_penalty=1.2,
28 pad_token_id=tokenizer.eos_token_id,
29)
30
31# Decode and print
32generated_text = tokenizer.decode(output_ids[0], skip_special_tokens=True)
33print(f"Generated Answer:\n{generated_text}")### Question: What is the role of the tumor microenvironment in cancer progression, and how does it influence the response to therapy?
### Answer:
The tumor microenvironment (TME) refers to the complex network of cells, extracellular matrix components, signaling molecules, and immune cells that surround a growing tumor. It plays an essential role in regulating various aspects of cancer development and progression...
### References:
1. Hanahan D, Weinberg RA. Hallmarks of Cancer: The Next Generation. Cell. 2011;144(5):646-74. doi:10.1016/j.cell.2011.03.019
2. Coussens LM, Pollard JW. Angiogenesis and Metastasis. Nature Reviews Cancer. 2006;6(1):57-68. doi:10.1038/nrc2210
3. Mantovani A, et al. Cancer's Educated Environment: How the Tumour Microenvironment Promotes Progression. Cell. 2017;168(6):988-1001.e15. doi:10.1016/j.cell.2017.02.011
4. Cheng YH, et al. Targeting the Tumor Microenvironment for Improved Therapy Response. Journal of Clinical Oncology. 2018;34(18_suppl):LBA10001. doi:10.1200/JCO.2018.34.18_suppl.LBA10001
5. Kang YS, et al. Role of the Tumor Microenvironment in Cancer Immunotherapy. Current Opinion in Pharmacology. 2018;30:101-108. doi:10.1016/j.ycoop.20