hamedbabaeigiglou commited on
Commit
e7c237e
·
verified ·
1 Parent(s): c11190b

minor update to readme

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