hamedbabaeigiglou commited on
Commit
889a456
·
verified ·
1 Parent(s): c760361

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
- - arts_and_humanities
10
  pretty_name: Arts And Humanities
11
  ---
12
  <div align="center">
@@ -59,32 +59,47 @@ ontology.load()
59
  data = ontology.extract()
60
  ```
61
 
 
62
  **How use the loaded dataset for LLM4OL Paradigm task settings?**
63
  ``` python
 
64
  from ontolearner import ChordOntology, LearnerPipeline, train_test_split
65
 
 
66
  ontology = ChordOntology()
67
- ontology.load()
68
  data = ontology.extract()
69
 
70
  # Split into train and test sets
71
- train_data, test_data = train_test_split(data, test_size=0.2)
72
 
73
- # Create a learning pipeline (for RAG-based learning)
 
74
  pipeline = LearnerPipeline(
75
- task = "term-typing", # Other options: "taxonomy-discovery" or "non-taxonomy-discovery"
76
- retriever_id = "sentence-transformers/all-MiniLM-L6-v2",
77
- llm_id = "mistralai/Mistral-7B-Instruct-v0.1",
78
- hf_token = "your_huggingface_token" # Only needed for gated models
 
79
  )
80
 
81
- # Train and evaluate
82
- results, metrics = pipeline.fit_predict_evaluate(
83
  train_data=train_data,
84
  test_data=test_data,
85
- top_k=3,
86
- test_limit=10
 
87
  )
 
 
 
 
 
 
 
 
 
88
  ```
89
 
90
  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
+ - arts-and-humanities
10
  pretty_name: Arts And Humanities
11
  ---
12
  <div align="center">
 
59
  data = ontology.extract()
60
  ```
61
 
62
+
63
  **How use the loaded dataset for LLM4OL Paradigm task settings?**
64
  ``` python
65
+ # Import core modules from the OntoLearner library
66
  from ontolearner import ChordOntology, LearnerPipeline, train_test_split
67
 
68
+ # Load the ChordOntology ontology, which contains concepts related to wines, their properties, and categories
69
  ontology = ChordOntology()
70
+ ontology.load() # Load entities, types, and structured term annotations from the ontology
71
  data = ontology.extract()
72
 
73
  # Split into train and test sets
74
+ train_data, test_data = train_test_split(data, test_size=0.2, random_state=42)
75
 
76
+ # Initialize a multi-component learning pipeline (retriever + LLM)
77
+ # This configuration enables a Retrieval-Augmented Generation (RAG) setup
78
  pipeline = LearnerPipeline(
79
+ retriever_id='sentence-transformers/all-MiniLM-L6-v2', # Dense retriever model for nearest neighbor search
80
+ llm_id='Qwen/Qwen2.5-0.5B-Instruct', # Lightweight instruction-tuned LLM for reasoning
81
+ hf_token='...', # Hugging Face token for accessing gated models
82
+ batch_size=32, # Batch size for training/prediction if supported
83
+ top_k=5 # Number of top retrievals to include in RAG prompting
84
  )
85
 
86
+ # Run the pipeline: training, prediction, and evaluation in one call
87
+ outputs = pipeline(
88
  train_data=train_data,
89
  test_data=test_data,
90
+ evaluate=True, # Compute metrics like precision, recall, and F1
91
+ task='term-typing' # Specifies the task
92
+ # Other options: "taxonomy-discovery" or "non-taxonomy-discovery"
93
  )
94
+
95
+ # Print final evaluation metrics
96
+ print("Metrics:", outputs['metrics'])
97
+
98
+ # Print the total time taken for the full pipeline execution
99
+ print("Elapsed time:", outputs['elapsed_time'])
100
+
101
+ # Print all outputs (including predictions)
102
+ print(outputs)
103
  ```
104
 
105
  For more detailed documentation, see the [![Documentation](https://img.shields.io/badge/Documentation-ontolearner.readthedocs.io-blue)](https://ontolearner.readthedocs.io)