Skip to content

Commit bd004db

Browse files
committed
add benchmarks and benchmarks results
1 parent c032131 commit bd004db

19 files changed

+797
-57
lines changed

examples/benchmarks/.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
OPENAI_APIKEY="your openai api key"
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
"""
2+
Basic example of scraping pipeline using SmartScraper from text
3+
"""
4+
5+
import os
6+
from scrapegraphai.graphs import SmartScraperGraph
7+
from scrapegraphai.utils import prettify_exec_info
8+
9+
files = ["inputs/example_1.txt", "inputs/example_2.txt"]
10+
tasks = ["List me all the projects with their description.",
11+
"List me all the articles with their description."]
12+
13+
14+
# ************************************************
15+
# Define the configuration for the graph
16+
# ************************************************
17+
18+
graph_config = {
19+
"llm": {
20+
"model": "ollama/mistral",
21+
"temperature": 0,
22+
"format": "json", # Ollama needs the format to be specified explicitly
23+
# "model_tokens": 2000, # set context length arbitrarily
24+
},
25+
"embeddings": {
26+
"model": "ollama/nomic-embed-text",
27+
"temperature": 0,
28+
}
29+
}
30+
31+
# ************************************************
32+
# Create the SmartScraperGraph instance and run it
33+
# ************************************************
34+
35+
for i in range(0, 2):
36+
with open(files[i], 'r', encoding="utf-8") as file:
37+
text = file.read()
38+
39+
smart_scraper_graph = SmartScraperGraph(
40+
prompt=tasks[i],
41+
source=text,
42+
config=graph_config
43+
)
44+
45+
result = smart_scraper_graph.run()
46+
print(result)
47+
# ************************************************
48+
# Get graph execution info
49+
# ************************************************
50+
51+
graph_exec_info = smart_scraper_graph.get_execution_info()
52+
print(prettify_exec_info(graph_exec_info))
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
"""
2+
Basic example of scraping pipeline using SmartScraper from text
3+
"""
4+
5+
import os
6+
from scrapegraphai.graphs import SmartScraperGraph
7+
from scrapegraphai.utils import prettify_exec_info
8+
9+
files = ["inputs/example_1.txt", "inputs/example_2.txt"]
10+
tasks = ["List me all the projects with their description.",
11+
"List me all the articles with their description."]
12+
13+
14+
# ************************************************
15+
# Define the configuration for the graph
16+
# ************************************************
17+
18+
graph_config = {
19+
"llm": {
20+
"model": "ollama/mistral",
21+
"temperature": 0,
22+
"format": "json", # Ollama needs the format to be specified explicitly
23+
# "model_tokens": 2000, # set context length arbitrarily
24+
"base_url": "http://localhost:11434",
25+
},
26+
"embeddings": {
27+
"model": "ollama/nomic-embed-text",
28+
"temperature": 0,
29+
"base_url": "http://localhost:11434",
30+
}
31+
}
32+
33+
# ************************************************
34+
# Create the SmartScraperGraph instance and run it
35+
# ************************************************
36+
37+
for i in range(0, 2):
38+
with open(files[i], 'r', encoding="utf-8") as file:
39+
text = file.read()
40+
41+
smart_scraper_graph = SmartScraperGraph(
42+
prompt=tasks[i],
43+
source=text,
44+
config=graph_config
45+
)
46+
47+
result = smart_scraper_graph.run()
48+
print(result)
49+
# ************************************************
50+
# Get graph execution info
51+
# ************************************************
52+
53+
graph_exec_info = smart_scraper_graph.get_execution_info()
54+
print(prettify_exec_info(graph_exec_info))
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
"""
2+
Basic example of scraping pipeline using SmartScraper from text
3+
"""
4+
5+
import os
6+
from dotenv import load_dotenv
7+
from scrapegraphai.graphs import SmartScraperGraph
8+
from scrapegraphai.utils import prettify_exec_info
9+
load_dotenv()
10+
11+
# ************************************************
12+
# Read the text file
13+
# ************************************************
14+
files = ["inputs/example_1.txt", "inputs/example_2.txt"]
15+
tasks = ["List me all the projects with their description.",
16+
"List me all the articles with their description."]
17+
18+
# ************************************************
19+
# Define the configuration for the graph
20+
# ************************************************
21+
22+
openai_key = os.getenv("GPT35_KEY")
23+
24+
graph_config = {
25+
"llm": {
26+
"api_key": openai_key,
27+
"model": "gpt-3.5-turbo",
28+
},
29+
}
30+
31+
# ************************************************
32+
# Create the SmartScraperGraph instance and run it
33+
# ************************************************
34+
35+
for i in range(0, 2):
36+
with open(files[i], 'r', encoding="utf-8") as file:
37+
text = file.read()
38+
39+
smart_scraper_graph = SmartScraperGraph(
40+
prompt=tasks[i],
41+
source=text,
42+
config=graph_config
43+
)
44+
45+
result = smart_scraper_graph.run()
46+
print(result)
47+
# ************************************************
48+
# Get graph execution info
49+
# ************************************************
50+
51+
graph_exec_info = smart_scraper_graph.get_execution_info()
52+
print(prettify_exec_info(graph_exec_info))
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
"""
2+
Basic example of scraping pipeline using SmartScraper from text
3+
"""
4+
5+
import os
6+
from dotenv import load_dotenv
7+
from scrapegraphai.graphs import SmartScraperGraph
8+
from scrapegraphai.utils import prettify_exec_info
9+
load_dotenv()
10+
11+
# ************************************************
12+
# Read the text file
13+
# ************************************************
14+
files = ["inputs/example_1.txt", "inputs/example_2.txt"]
15+
tasks = ["List me all the projects with their description.",
16+
"List me all the articles with their description."]
17+
18+
19+
# ************************************************
20+
# Define the configuration for the graph
21+
# ************************************************
22+
23+
openai_key = os.getenv("GPT4_KEY")
24+
25+
graph_config = {
26+
"llm": {
27+
"api_key": openai_key,
28+
"model": "gpt-4-turbo-preview",
29+
},
30+
}
31+
32+
# ************************************************
33+
# Create the SmartScraperGraph instance and run it
34+
# ************************************************
35+
36+
for i in range(0, 2):
37+
with open(files[i], 'r', encoding="utf-8") as file:
38+
text = file.read()
39+
40+
smart_scraper_graph = SmartScraperGraph(
41+
prompt=tasks[i],
42+
source=text,
43+
config=graph_config
44+
)
45+
46+
result = smart_scraper_graph.run()
47+
print(result)
48+
# ************************************************
49+
# Get graph execution info
50+
# ************************************************
51+
52+
graph_exec_info = smart_scraper_graph.get_execution_info()
53+
print(prettify_exec_info(graph_exec_info))
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
<body class="fixed-top-nav " style="padding-top: 57px;">
2+
<header>
3+
<nav id="navbar" class="navbar navbar-light navbar-expand-sm fixed-top">
4+
<div class="container">
5+
<a class="navbar-brand title font-weight-lighter" href="/"><span class="font-weight-bold">Marco&nbsp;</span>Perini</a> <button class="navbar-toggler collapsed ml-auto" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar top-bar"></span> <span class="icon-bar middle-bar"></span> <span class="icon-bar bottom-bar"></span> </button>
6+
<div class="collapse navbar-collapse text-right" id="navbarNav">
7+
<ul class="navbar-nav ml-auto flex-nowrap">
8+
<li class="nav-item "> <a class="nav-link" href="/">About</a> </li>
9+
<li class="nav-item dropdown active">
10+
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Projects<span class="sr-only">(current)</span></a>
11+
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdown">
12+
<a class="dropdown-item" href="/projects/">Projects</a>
13+
<div class="dropdown-divider"></div>
14+
<a class="dropdown-item" href="/competitions/">Competitions</a>
15+
</div>
16+
</li>
17+
<li class="nav-item "> <a class="nav-link" href="/cv/">CV</a> </li>
18+
<li class="toggle-container"> <button id="light-toggle" title="Change theme"> <i class="fa-solid fa-moon"></i> <i class="fa-solid fa-sun"></i> </button> </li>
19+
</ul>
20+
</div>
21+
</div>
22+
</nav>
23+
<progress id="progress" value="0" max="284" style="top: 57px;">
24+
<div class="progress-container"> <span class="progress-bar"></span> </div>
25+
</progress>
26+
</header>
27+
<div class="container mt-5">
28+
<div class="post">
29+
<header class="post-header">
30+
<h1 class="post-title">Projects</h1>
31+
<p class="post-description"></p>
32+
</header>
33+
<article>
34+
<div class="projects">
35+
<div class="grid" style="position: relative; height: 861.992px;">
36+
<div class="grid-sizer"></div>
37+
<div class="grid-item" style="position: absolute; left: 0px; top: 0px;">
38+
<a href="/projects/rotary-pendulum-rl/">
39+
<div class="card hoverable">
40+
<figure>
41+
<picture> <img src="/assets/img/rotary_pybullet.jpg" width="auto" height="auto" alt="project thumbnail" onerror="this.onerror=null; $('.responsive-img-srcset').remove();"> </picture>
42+
</figure>
43+
<div class="card-body">
44+
<h4 class="card-title">Rotary Pendulum RL</h4>
45+
<p class="card-text">Open Source project aimed at controlling a real life rotary pendulum using RL algorithms</p>
46+
<div class="row ml-1 mr-1 p-0"> </div>
47+
</div>
48+
</div>
49+
</a>
50+
</div>
51+
<div class="grid-sizer"></div>
52+
<div class="grid-item" style="position: absolute; left: 260px; top: 0px;">
53+
<a href="https://github.com/PeriniM/DQN-SwingUp" rel="external nofollow noopener" target="_blank">
54+
<div class="card hoverable">
55+
<figure>
56+
<picture> <img src="/assets/img/value-policy-heatmaps.jpg" width="auto" height="auto" alt="project thumbnail" onerror="this.onerror=null; $('.responsive-img-srcset').remove();"> </picture>
57+
</figure>
58+
<div class="card-body">
59+
<h4 class="card-title">DQN Implementation from scratch</h4>
60+
<p class="card-text">Developed a Deep Q-Network algorithm to train a simple and double pendulum</p>
61+
<div class="row ml-1 mr-1 p-0"> </div>
62+
</div>
63+
</div>
64+
</a>
65+
</div>
66+
<div class="grid-sizer"></div>
67+
<div class="grid-item" style="position: absolute; left: 0px; top: 447.414px;">
68+
<a href="https://github.com/PeriniM/Multi-Agents-HAED" rel="external nofollow noopener" target="_blank">
69+
<div class="card hoverable">
70+
<figure>
71+
<picture> <img src="/assets/img/multi_agents_haed.gif" width="auto" height="auto" alt="project thumbnail" onerror="this.onerror=null; $('.responsive-img-srcset').remove();"> </picture>
72+
</figure>
73+
<div class="card-body">
74+
<h4 class="card-title">Multi Agents HAED</h4>
75+
<p class="card-text">University project which focuses on simulating a multi-agent system to perform environment mapping. Agents, equipped with sensors, explore and record their surroundings, considering uncertainties in their readings.</p>
76+
<div class="row ml-1 mr-1 p-0"> </div>
77+
</div>
78+
</div>
79+
</a>
80+
</div>
81+
<div class="grid-sizer"></div>
82+
<div class="grid-item" style="position: absolute; left: 260px; top: 370.172px;">
83+
<a href="/projects/wireless-esc-drone/">
84+
<div class="card hoverable">
85+
<figure>
86+
<picture> <img src="/assets/img/wireless_esc.gif" width="auto" height="auto" alt="project thumbnail" onerror="this.onerror=null; $('.responsive-img-srcset').remove();"> </picture>
87+
</figure>
88+
<div class="card-body">
89+
<h4 class="card-title">Wireless ESC for Modular Drones</h4>
90+
<p class="card-text">Modular drone architecture proposal and proof of concept. The project received maximum grade.</p>
91+
<div class="row ml-1 mr-1 p-0"> </div>
92+
</div>
93+
</div>
94+
</a>
95+
</div>
96+
</div>
97+
</div>
98+
</article>
99+
</div>
100+
</div>
101+
<footer class="fixed-bottom">
102+
<div class="container mt-0"> © Copyright 2023 Marco Perini. Powered by <a href="https://jekyllrb.com/" target="_blank" rel="external nofollow noopener">Jekyll</a> with <a href="https://github.com/alshedivat/al-folio" rel="external nofollow noopener" target="_blank">al-folio</a> theme. Hosted by <a href="https://pages.github.com/" target="_blank" rel="external nofollow noopener">GitHub Pages</a>. </div>
103+
</footer>
104+
<div class="hiddendiv common"></div>
105+
</body>

0 commit comments

Comments
 (0)