Spaces:
Runtime error
Runtime error
hacpdsae2023
commited on
Commit
·
1db9e9a
1
Parent(s):
d0f7403
Documentation
Browse files
app.py
CHANGED
@@ -4,8 +4,15 @@ import networkx as nx
|
|
4 |
import numpy as np
|
5 |
dataset = load_dataset("roneneldan/TinyStories")
|
6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
st.write(dataset['train'][10]['text'])
|
8 |
|
|
|
9 |
threshhold = st.slider('Threshhold',0.0,1.0,step=0.1)
|
10 |
|
11 |
#-------------------------------------------------------------
|
@@ -39,6 +46,8 @@ for i in range(len(sentences)):
|
|
39 |
#G = nx.from_numpy_array(A)
|
40 |
G = nx.from_numpy_array(cosine_scores.numpy()>threshhold)
|
41 |
|
|
|
|
|
42 |
|
43 |
#-------------------------------------------------------------
|
44 |
#-------------------------------------------------------------
|
@@ -98,4 +107,5 @@ return_value = agraph(nodes=nodes,
|
|
98 |
edges=edges,
|
99 |
config=config)
|
100 |
|
|
|
101 |
st.write(str(nx.laplacian_centrality(G)))
|
|
|
4 |
import numpy as np
|
5 |
dataset = load_dataset("roneneldan/TinyStories")
|
6 |
|
7 |
+
st.markdown('# Short Stories, networks and connections')
|
8 |
+
st.markdown('In this example we consider the semantic similarity between short stories generatited by GenAI.')
|
9 |
+
st.markdown('We study the relationshis between the stories using a network. The laplacian connectivity provides inights about the closeness of the graph')
|
10 |
+
|
11 |
+
st.markdown('# Short Stories')
|
12 |
+
st.markdown('We are using a sample fo the TinyStories dataset from roneneldan work')
|
13 |
st.write(dataset['train'][10]['text'])
|
14 |
|
15 |
+
st.markdown('The threshold changes the level of connectivity in the network. The reange is from 0 (less similar) to 1 (completely similar)')
|
16 |
threshhold = st.slider('Threshhold',0.0,1.0,step=0.1)
|
17 |
|
18 |
#-------------------------------------------------------------
|
|
|
46 |
#G = nx.from_numpy_array(A)
|
47 |
G = nx.from_numpy_array(cosine_scores.numpy()>threshhold)
|
48 |
|
49 |
+
st.markdown('We can visualize the similarity between the shorts stories as a network. It the similarity is greater than the threshold, the two nodes are conencted')
|
50 |
+
|
51 |
|
52 |
#-------------------------------------------------------------
|
53 |
#-------------------------------------------------------------
|
|
|
107 |
edges=edges,
|
108 |
config=config)
|
109 |
|
110 |
+
st.markdown('The Laplacian centrality is a measure of closeness')
|
111 |
st.write(str(nx.laplacian_centrality(G)))
|