First commit
Browse files- README.md +2 -2
- aecaihub.parquet +3 -0
- app.py +92 -0
- requirements.txt +5 -0
README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
---
|
2 |
-
title:
|
3 |
-
emoji:
|
4 |
colorFrom: pink
|
5 |
colorTo: gray
|
6 |
sdk: gradio
|
|
|
1 |
---
|
2 |
+
title: AEC AI Tools - Semantic Search
|
3 |
+
emoji: π’
|
4 |
colorFrom: pink
|
5 |
colorTo: gray
|
6 |
sdk: gradio
|
aecaihub.parquet
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:b57907b71b89280b8358581f5a8c27c2ed7d99278b7cfde88dfeeed5ca442e1b
|
3 |
+
size 2139416
|
app.py
ADDED
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import pandas as pd
|
3 |
+
from langchain_community.vectorstores import SKLearnVectorStore
|
4 |
+
from langchain_community.embeddings import HuggingFaceBgeEmbeddings
|
5 |
+
|
6 |
+
cols = [
|
7 |
+
"Name",
|
8 |
+
"Description",
|
9 |
+
"Category",
|
10 |
+
"AI-Driven",
|
11 |
+
"Champion",
|
12 |
+
"Match score",
|
13 |
+
]
|
14 |
+
|
15 |
+
persist_path = "aecaihub.parquet"
|
16 |
+
|
17 |
+
model_name = "BAAI/bge-small-en-v1.5"
|
18 |
+
encode_kwargs = {'normalize_embeddings': True,"show_progress_bar":False,"batch_size":1} # set True to compute cosine similarity
|
19 |
+
embeddings_function = HuggingFaceBgeEmbeddings(
|
20 |
+
model_name=model_name,
|
21 |
+
encode_kwargs=encode_kwargs,
|
22 |
+
query_instruction="Represent this sentence for searching relevant passages: "
|
23 |
+
)
|
24 |
+
|
25 |
+
|
26 |
+
vector_store = SKLearnVectorStore(
|
27 |
+
embedding=embeddings_function, persist_path=persist_path, serializer="parquet"
|
28 |
+
)
|
29 |
+
|
30 |
+
def predict(query,k):
|
31 |
+
|
32 |
+
docs = vector_store.similarity_search_with_score(query,k = k)
|
33 |
+
|
34 |
+
df_results = []
|
35 |
+
for doc,score in docs:
|
36 |
+
m = doc.metadata
|
37 |
+
result_doc = {
|
38 |
+
"Name":f"**[{m['name']}]({m['url']})**",
|
39 |
+
"Description":doc.page_content,
|
40 |
+
"Category":m["category"],
|
41 |
+
"AI-Driven":m["ai_driven"],
|
42 |
+
"Champion":m["champion"],
|
43 |
+
"Match score":round(1-score,3),
|
44 |
+
}
|
45 |
+
|
46 |
+
df_results.append(result_doc)
|
47 |
+
df_results = pd.DataFrame(df_results)
|
48 |
+
return df_results
|
49 |
+
|
50 |
+
|
51 |
+
examples = [
|
52 |
+
"Tool to generate floor plans"
|
53 |
+
"AI tool for comparing building materials and sustainability",
|
54 |
+
"3D model library with image search function",
|
55 |
+
"AI-powered 3D design tool for architects and interior designers",
|
56 |
+
"Software for extracting 3D models from videos",
|
57 |
+
"AI tool for comprehensive utility data in infrastructure projects",
|
58 |
+
"AI for generating creative content in design projects",
|
59 |
+
"AI tool to convert text into architectural videos",
|
60 |
+
"AI solutions for low carbon design and data mining in architecture",
|
61 |
+
"Software for construction quantity estimation and progress tracking",
|
62 |
+
"AI interior design tool for automatic room designs"
|
63 |
+
]
|
64 |
+
|
65 |
+
# Create the Gradio interface
|
66 |
+
with gr.Blocks() as demo:
|
67 |
+
gr.Markdown("""
|
68 |
+
# π’ AEC AI Hub - Semantic Search Engine
|
69 |
+
This tool uses semantic search to find AI tools for Architecture Engineering and Construction (AEC) based on your question.
|
70 |
+
The database is drawn from the [great work](https://stjepanmikulic.notion.site/AEC-AI-Hub-b6e6eebe88094e0e9b4995da38e96768) of [Stjepan Mikulic](https://www.linkedin.com/in/stjepanmikulic/)
|
71 |
+
""")
|
72 |
+
|
73 |
+
with gr.Row():
|
74 |
+
search_bar = gr.Textbox(label="Ask you question here",scale = 2)
|
75 |
+
k = gr.Slider(minimum=1, maximum=20, value=5, label="Number of results", step=1,interactive=True)
|
76 |
+
examples = gr.Examples(
|
77 |
+
examples,search_bar, label="Examples",
|
78 |
+
)
|
79 |
+
button = gr.Button("π Search")
|
80 |
+
gr.Markdown("## AI Tools")
|
81 |
+
result_df = gr.Dataframe(
|
82 |
+
headers=cols,
|
83 |
+
wrap=True,
|
84 |
+
datatype=["markdown","str","str","str","str","str"],
|
85 |
+
column_widths = ["10%","50%","10%","10%","10%","10%"],
|
86 |
+
)
|
87 |
+
|
88 |
+
(button
|
89 |
+
.click(predict, inputs = [search_bar,k], outputs=[result_df])
|
90 |
+
)
|
91 |
+
|
92 |
+
demo.launch()
|
requirements.txt
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
langchain==0.1.0
|
2 |
+
sentence-transformers
|
3 |
+
huggingface-hub
|
4 |
+
gradio
|
5 |
+
pandas
|