hamedbabaeigiglou commited on
Commit
6fb711c
·
verified ·
1 Parent(s): 904293a

minor update to readme

Browse files
Files changed (1) hide show
  1. README.md +27 -12
README.md CHANGED
@@ -6,7 +6,7 @@ language:
6
  tags:
7
  - OntoLearner
8
  - ontology-learning
9
- - materials_science_and_engineering
10
  pretty_name: Materials Science And Engineering
11
  ---
12
  <div align="center">
@@ -103,32 +103,47 @@ ontology.load()
103
  data = ontology.extract()
104
  ```
105
 
 
106
  **How use the loaded dataset for LLM4OL Paradigm task settings?**
107
  ``` python
 
108
  from ontolearner import AMOntology, LearnerPipeline, train_test_split
109
 
 
110
  ontology = AMOntology()
111
- ontology.load()
112
  data = ontology.extract()
113
 
114
  # Split into train and test sets
115
- train_data, test_data = train_test_split(data, test_size=0.2)
116
 
117
- # Create a learning pipeline (for RAG-based learning)
 
118
  pipeline = LearnerPipeline(
119
- task = "term-typing", # Other options: "taxonomy-discovery" or "non-taxonomy-discovery"
120
- retriever_id = "sentence-transformers/all-MiniLM-L6-v2",
121
- llm_id = "mistralai/Mistral-7B-Instruct-v0.1",
122
- hf_token = "your_huggingface_token" # Only needed for gated models
 
123
  )
124
 
125
- # Train and evaluate
126
- results, metrics = pipeline.fit_predict_evaluate(
127
  train_data=train_data,
128
  test_data=test_data,
129
- top_k=3,
130
- test_limit=10
 
131
  )
 
 
 
 
 
 
 
 
 
132
  ```
133
 
134
  For more detailed documentation, see the [![Documentation](https://img.shields.io/badge/Documentation-ontolearner.readthedocs.io-blue)](https://ontolearner.readthedocs.io)
 
6
  tags:
7
  - OntoLearner
8
  - ontology-learning
9
+ - materials-science-and-engineering
10
  pretty_name: Materials Science And Engineering
11
  ---
12
  <div align="center">
 
103
  data = ontology.extract()
104
  ```
105
 
106
+
107
  **How use the loaded dataset for LLM4OL Paradigm task settings?**
108
  ``` python
109
+ # Import core modules from the OntoLearner library
110
  from ontolearner import AMOntology, LearnerPipeline, train_test_split
111
 
112
+ # Load the AMOntology ontology, which contains concepts related to wines, their properties, and categories
113
  ontology = AMOntology()
114
+ ontology.load() # Load entities, types, and structured term annotations from the ontology
115
  data = ontology.extract()
116
 
117
  # Split into train and test sets
118
+ train_data, test_data = train_test_split(data, test_size=0.2, random_state=42)
119
 
120
+ # Initialize a multi-component learning pipeline (retriever + LLM)
121
+ # This configuration enables a Retrieval-Augmented Generation (RAG) setup
122
  pipeline = LearnerPipeline(
123
+ retriever_id='sentence-transformers/all-MiniLM-L6-v2', # Dense retriever model for nearest neighbor search
124
+ llm_id='Qwen/Qwen2.5-0.5B-Instruct', # Lightweight instruction-tuned LLM for reasoning
125
+ hf_token='...', # Hugging Face token for accessing gated models
126
+ batch_size=32, # Batch size for training/prediction if supported
127
+ top_k=5 # Number of top retrievals to include in RAG prompting
128
  )
129
 
130
+ # Run the pipeline: training, prediction, and evaluation in one call
131
+ outputs = pipeline(
132
  train_data=train_data,
133
  test_data=test_data,
134
+ evaluate=True, # Compute metrics like precision, recall, and F1
135
+ task='term-typing' # Specifies the task
136
+ # Other options: "taxonomy-discovery" or "non-taxonomy-discovery"
137
  )
138
+
139
+ # Print final evaluation metrics
140
+ print("Metrics:", outputs['metrics'])
141
+
142
+ # Print the total time taken for the full pipeline execution
143
+ print("Elapsed time:", outputs['elapsed_time'])
144
+
145
+ # Print all outputs (including predictions)
146
+ print(outputs)
147
  ```
148
 
149
  For more detailed documentation, see the [![Documentation](https://img.shields.io/badge/Documentation-ontolearner.readthedocs.io-blue)](https://ontolearner.readthedocs.io)