Skip to content

Commit

Permalink
add Falcon files
Browse files Browse the repository at this point in the history
  • Loading branch information
svlandeg committed Jul 14, 2023
1 parent 5db2416 commit 0d50bc9
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 3 deletions.
17 changes: 17 additions & 0 deletions tutorials/llm_clinical_trials/configs/ner_dolly.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[nlp]
lang = "en"
pipeline = ["llm"]
batch_size = 128

[components]

[components.llm]
factory = "llm"

[components.llm.model]
@llm_models = "spacy.Dolly.v1"
name = "dolly-v2-3b"

[components.llm.task]
@llm_tasks = "spacy.NER.v2"
labels = "Drug,Dose"
17 changes: 17 additions & 0 deletions tutorials/llm_clinical_trials/configs/ner_falcon.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[nlp]
lang = "en"
pipeline = ["llm"]
batch_size = 128

[components]

[components.llm]
factory = "llm"

[components.llm.model]
@llm_models = "spacy.Falcon.v1"
name = "falcon-7b-instruct"

[components.llm.task]
@llm_tasks = "spacy.NER.v2"
labels = "Drug,Dose"
4 changes: 4 additions & 0 deletions tutorials/llm_clinical_trials/falcon_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
cupy-cuda117
torch==1.13.1+cu117 -f https://download.pytorch.org/whl/torch_stable.html
transformers
einops
2 changes: 1 addition & 1 deletion tutorials/llm_clinical_trials/project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ title: 'Clinical trial results extraction with LLMs'
description: "Using an LLM in a spaCy pipeline to extract patient groups, treatments and outcomes in clinical trials."

vars:
ner_config: "ner_openai.cfg"
ner_config: "ner_dolly.cfg" # "ner_falcon.cfg" # "ner_openai.cfg"
trial_config: "trial_openai.cfg"
pmid: 27144689

Expand Down
8 changes: 6 additions & 2 deletions tutorials/llm_clinical_trials/scripts/visualise_entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,12 @@ def visualise_entities(pmid: int, config_path: Path, verbose: bool = False):
text = read_trial(pmid, verbose=verbose)
nlp = assemble(config_path)
doc = nlp(text)
options = {"ents": ["Drug", "Dose"], "colors": {"Drug": "pink", "Dose": "orange"}}
displacy.serve(doc, style="ent", options=options)
# options = {"ents": ["Drug", "Dose"], "colors": {"Drug": "pink", "Dose": "orange"}}
ents = list(doc.ents)
print("ents", len(ents))
for ent in ents:
print(ent.text, ent.label_)
#displacy.serve(doc, style="ent", options=options)


if __name__ == "__main__":
Expand Down

0 comments on commit 0d50bc9

Please sign in to comment.