Transformers
Italian
English
semantic-search
explainable-ai
faiss
ai-ethics
responsible-ai
llm
prompt-engineering
multimodal-ai
ai-transparency
ethical-intelligence
explainable-llm
cognitive-ai
ethical-ai
scientific-retrieval
modular-ai
memory-augmented-llm
trustworthy-ai
reasoning-engine
ai-alignment
next-gen-llm
thinking-machines
open-source-ai
explainability
ai-research
semantic audit
cognitive agent
human-centered-ai
Create evaluation/automatic_review.py
Browse files
src/evaluation/automatic_review.py
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# © 2025 Elena Marziali — Code released under Apache 2.0 license.
|
| 2 |
+
# See LICENSE in the repository for details.
|
| 3 |
+
# Removal of this copyright is prohibited.
|
| 4 |
+
|
| 5 |
+
# Verify the methodology of the text using an LLM
|
| 6 |
+
def verify_methodology(paper_text):
|
| 7 |
+
prompt = f"Analyze the 'Methods' section and check whether the experiment is replicable:\n{paper_text}"
|
| 8 |
+
return llm.invoke(prompt.strip())
|
| 9 |
+
|
| 10 |
+
# Enrich the context of the response
|
| 11 |
+
async def enrich_context(query):
|
| 12 |
+
""" Retrieves scientific data to enrich the LLM's context. """
|
| 13 |
+
articles = await search_multi_database(query)
|
| 14 |
+
|
| 15 |
+
context = "\n".join([f"**{a['title']}** - {a['abstract']}" for a in articles[:3]]) # Select the first 3 articles
|
| 16 |
+
return context if context else "No relevant scientific articles found."
|
| 17 |
+
|
| 18 |
+
# Automated review of scientific papers
|
| 19 |
+
async def review_paper(paper_text):
|
| 20 |
+
""" Analyzes the paper's methodology and citations. """
|
| 21 |
+
methodology = await verify_methodology(paper_text)
|
| 22 |
+
citations = await verify_citations(paper_text)
|
| 23 |
+
|
| 24 |
+
review = {
|
| 25 |
+
"methodology_analysis": methodology,
|
| 26 |
+
"citation_validation": citations,
|
| 27 |
+
"improvement_suggestions": suggest_improvements(paper_text)
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
return review
|
| 31 |
+
|
| 32 |
+
# === Asynchronous function for scientific search and analysis using SciBERT ===
|
| 33 |
+
async def search_arxiv_async(query):
|
| 34 |
+
# TODO: Implement asynchronous API call to arXiv or other repository
|
| 35 |
+
return [] # Placeholder article list
|
| 36 |
+
|
| 37 |
+
async def analyze_scientific_text(problem, concept):
|
| 38 |
+
articles = await search_arxiv_async(concept)
|
| 39 |
+
context = "\n".join([f"{a.get('title', '')}: {a.get('abstract', '')[:300]}..." for a in articles])
|
| 40 |
+
scibert_response = scibert_model(question=problem, context=context)
|
| 41 |
+
return scibert_response.get("answer", "")
|
| 42 |
+
|
| 43 |
+
# === Function to search for experimental data ===
|
| 44 |
+
def search_experimental_data(query):
|
| 45 |
+
url = f"https://api.openphysicsdata.org/search?query={query}"
|
| 46 |
+
response = requests.get(url)
|
| 47 |
+
if response.status_code == 200:
|
| 48 |
+
return response.json()
|
| 49 |
+
else:
|
| 50 |
+
return "No experimental data found."
|