Views
No views yet
aksw/Bike-specieBike-specie is a Medium fine-tuned language model designed to extract biochemical collection species from scientific text articles. It is ideal for Information Retrieval systems based on Biohemical Knowledge Extraction.unsloth, torch and CUDA dependencies:pip install unsloth torch1from unsloth import FastLanguageModel
2import torch
3
4class BiKESpecieExtractor:
5 def __init__(self, model_name: str, max_seq_length: int = 32768, load_in_4bit: bool = True):
6 self.model, self.tokenizer = FastLanguageModel.from_pretrained(
7 model_name=model_name,
8 max_seq_length=max_seq_length,
9 load_in_4bit=load_in_4bit
10 )
11 _ = FastLanguageModel.for_inference(self.model)
12
13 def build_prompt(self, article_text: str) -> list:
14 return [
15 {"role": "system", "content": (
16 "You are a scientist trained in chemistry.\n"
17 "You must extract information from scientific papers identifying relevant properties associated with each natural product discussed in the academic publication.\n"
18 "For each paper, you have to analyze the content (text) to identify the *Collection Specie*, i.e., Species from which natural products were extracted. Provide the scientific name, binomial form. Family name can be provided. For example Tithonia diversifolia, Styrax camporum (Styracaceae), or Colletotrichum gloeosporioides (Phyllachoraceae).\n"
19 "Your output should be a list with the collection species. Return only the list, without any additional information.\n"
20 )},
21 {"role": "user", "content": article_text}
22 ]
23
24 def extract_specie(self, article_text: str, temperature: float = 0.01, max_new_tokens: int = 1024) -> str:
25 si = "<|im_start|>assistant<|im_sep|>"
26 sf = "<|im_end|>"
27 messages = self.build_prompt(article_text)
28 inputs = self.tokenizer.apply_chat_template(
29 messages, tokenize=True, add_generation_prompt=True, return_tensors="pt"
30 ).to("cuda")
31 outputs = self.model.generate(inputs, max_new_tokens=max_new_tokens, use_cache=True, temperature=temperature, min_p=0.1)
32 decoded = self.tokenizer.batch_decode(outputs)[0]
33 parsed = decoded[decoded.find(si):].replace(si, "").replace(sf, "")
34 try:
35 l = eval(parsed)
36 except:
37 l = parsed
38 print('Your output is not a list, you will need one more preprocessing step.')
39
40 return l
41
42# --- Using the model ---
43if __name__ == "__main__":
44 extractor = BiKESpecieExtractor(model_name="aksw/Bike-specie")
45 text = "Title, Abstract, Introduction, Background, Method, Results, Conclusion, References."
46 list_species = extractor.extract_specie(text)
47 print(list_species)@inproceedings{ref:doCarmo2025,
title={Improving Natural Product Knowledge Extraction from Academic Literature with Enhanced PDF Text Extraction and Large Language Models},
author={Viviurka do Carmo, Paulo and Silva G{\^o}lo, Marcos Paulo and Gwozdz, Jonas and Marx, Edgard and Marcondes Marcacini, Ricardo},
booktitle={Proceedings of the 40th ACM/SIGAPP Symposium on Applied Computing},
pages={980--987},
year={2025}
}