File size: 11,500 Bytes
0d3b770
 
097f973
09b648b
 
674de7c
6ca1b39
a14002e
674de7c
 
 
 
 
 
 
1146df3
 
 
 
 
 
 
 
 
 
 
 
674de7c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5beb9ef
674de7c
 
 
0c71419
674de7c
 
 
 
5464361
674de7c
 
 
07d605f
 
 
744aead
4fdc42e
07d605f
 
 
 
 
ab5426b
674de7c
5464361
ab5426b
f335638
5464361
fe19668
674de7c
 
 
31ac05c
a674250
 
fe19668
f51df89
fe19668
31ac05c
3cdd434
31ac05c
 
4fdc42e
31ac05c
097f973
31ac05c
d5ef006
 
 
74cb3e0
2880c10
17bfcb1
a2d6739
c0c1816
33565d1
2880c10
 
 
093cfc0
c0c1816
 
093cfc0
 
 
 
 
 
 
17bfcb1
2880c10
 
17bfcb1
c0c1816
2880c10
da91567
2880c10
 
 
 
22f15f2
674de7c
 
 
 
 
 
 
25bee72
674de7c
 
e9b7721
 
85a22b9
212803e
0d3b770
a14002e
c63e932
31ba554
a14002e
 
 
 
 
 
 
 
 
 
 
 
618bce3
85a22b9
212803e
 
 
 
 
 
85a22b9
98a2e37
1dc77a9
85a22b9
1dc77a9
39fe403
 
341fdde
39fe403
341fdde
a463b89
a14002e
 
 
 
a463b89
a14002e
 
 
 
 
 
 
 
 
 
deb32c3
22f968f
 
212803e
 
d099849
6998231
212803e
 
 
8eb51bf
 
013a409
 
 
2e26803
 
013a409
2e26803
 
 
d099849
 
f941ccb
d099849
0d3b770
 
cde5b6e
22f968f
 
 
 
1146df3
22f968f
d099849
0d3b770
618bce3
 
0d3b770
a14002e
d099849
1146df3
0d3b770
d9b19b2
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
from textblob import TextBlob
import gradio as gr
import math
import os 
os.system("python -m textblob.download_corpora")
control_json={'control':'0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ','char':'','leng':62}
string_json={'control':'0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMN','char':'OPQRSTUVWXYZ','leng':50}
cont_list=list(string_json['control'])




text="""
I asked Generative AI Models about their context window. Their response was intriguing.
The context window for a large language model (LLM) like OpenAI’s GPT refers to the maximum amount of text the model can consider at any one time when generating a response. This includes both the prompt provided by the user and the model’s generated text.
In practical terms, the context window limits how much previous dialogue the model can “remember” during an interaction. If the interaction exceeds the context window, the model loses access to the earliest parts of the conversation. This limitation can impact the model’s consistency in long conversations or complex tasks.
I asked Generative AI Models about their context window. Their response was intriguing.
The context window for a large language model (LLM) like OpenAI’s GPT refers to the maximum amount of text the model can consider at any one time when generating a response. This includes both the prompt provided by the user and the model’s generated text.
In practical terms, the context window limits how much previous dialogue the model can “remember” during an interaction. If the interaction exceeds the context window, the model loses access to the earliest parts of the conversation. This limitation can impact the model’s consistency in long conversations or complex tasks.
I asked Generative AI Models about their context window. Their response was intriguing.
The context window for a large language model (LLM) like OpenAI’s GPT refers to the maximum amount of text the model can consider at any one time when generating a response. This includes both the prompt provided by the user and the model’s generated text.
In practical terms, the context window limits how much previous dialogue the model can “remember” during an interaction. If the interaction exceeds the context window, the model loses access to the earliest parts of the conversation. This limitation can impact the model’s consistency in long conversations or complex tasks.
I asked Generative AI Models about their context window. Their response was intriguing.
The context window for a large language model (LLM) like OpenAI’s GPT refers to the maximum amount of text the model can consider at any one time when generating a response. This includes both the prompt provided by the user and the model’s generated text.
In practical terms, the context window limits how much previous dialogue the model can “remember” during an interaction. If the interaction exceeds the context window, the model loses access to the earliest parts of the conversation. This limitation can impact the model’s consistency in long conversations or complex tasks.
I asked Generative AI Models about their context window. Their response was intriguing.
The context window for a large language model (LLM) like OpenAI’s GPT refers to the maximum amount of text the model can consider at any one time when generating a response. This includes both the prompt provided by the user and the model’s generated text.
In practical terms, the context window limits how much previous dialogue the model can “remember” during an interaction. If the interaction exceeds the context window, the model loses access to the earliest parts of the conversation. This limitation can impact the model’s consistency in long conversations or complex tasks.
"""

def assign_val(inp, rng, cnt, limit):
    if go:            
        for ea in range(rng):
            if go:      
                noun_list[str(noun)].append(f'{a}{cont_list[b]}{cont_list[c]}{cont_list[d]}')   
                
                if json_object[f'{a}{cont_list[b]}{cont_list[c]}{cont_list[d]}']=='ZNNN':
                    a="Y"
                    b=0
                    c=0
                    d=0

                
                if cnt == key_cnt-1:
                    print('done')
                    go=False
                    print(list(json_object.keys())[-1])
                else:
                    cnt+=1


def get_nouns(text=text,steps=1):
    control_len=control_json['leng']-steps
    control_char=list(control_json['control'][:control_len])
    control_val=list(control_json['control'][control_len:])
    char_len=len(control_char)
    val_len=len(control_val)
    print(control_char)
    print(control_val)
    json_object={}
    sen_list=[]
    noun_list={}
    noun_box=[]
    #print(text)
    blob = TextBlob(text)
    for sentence in blob.sentences:
        sen_list.append(str(sentence))


    noun_box=[]
    for ea in blob.parse().split(" "):
        #print(ea)
        n=ea.split("/")
        if n[1] == "NN":
            noun_box.append(n[0])

        
    print(sen_list)
    key_cnt=len(sen_list)
    noun_cnt=len(noun_box)
    print(key_cnt)
    print(noun_cnt)
    
    big_cnt=0
    cnt=0
    go=True
    a="Z"

    step_allot=char_len**steps
    print(step_allot)
    div_raw=(step_allot/noun_cnt)
    print(div_raw)
    div_steps=int(step_allot/noun_cnt)
    print(div_steps)
    div_remain=div_raw-div_steps
    print(div_remain)
    steps_mult=div_remain*char_len
    #steps_mult=div_remain*char_len
    print(steps_mult)
    print(math.ceil(steps_mult))
    step_list=[]

    step_control=""
    step_cont_box=[]
    for ii in range(steps):
        print(ii)
        step_cont_box.append(0)
    #print (step_cont_box)
    mod=0
    pos=len(step_cont_box)-1
    if go:
        for i, ea in enumerate(noun_box):
            if go:
                if cnt > char_len+1:
                    go1=True
                    for ii,ev in enumerate(step_cont_box):
                        if go:
                            if ev >= char_len:
                                step_cont_box[ii]=0
                                if go1==True:
                                    step_cont_box[ii-1]=step_cont_box[ii-1]+1
                                    go1=False
                                
                    #pos-=1
                    cnt=0
                else:
                    #step_cont_box[pos]=control_char[cnt]
                    step_cont_box[pos]=cnt
                    cnt+=1
                print(step_cont_box)
                big_cnt+=1
                if big_cnt==noun_cnt:
                    print("DONE")
                    go=False
    return json_object,noun_list




def get_nouns_OG(text,steps=1):
    control_len=control_json['leng']-steps
    control_new=control_json['control'][:control_len]
    control_char=control_json['control'][control_len:]
    print(control_new)
    print(control_char)
    json_object={}
    sen_list=[]
    noun_list={}
    noun_box=[]
    blob = TextBlob(text)
    for sentence in blob.sentences:
        sen_list.append(str(sentence))
    key_cnt=len(sen_list)
    cnt=0
    go=True
    a="Z"
    if go:            
        for ea in range(10):
            if go:            
                for b in range(50):
                    if go:
                        for c in range(50):
                            if go:
                                for d in range(50):
                                    if go:
                                        blob_n = TextBlob(sen_list[cnt])
                                        noun_p=blob_n.noun_phrases
                                        noun_box=[]
                                        for ea in blob_n.parse().split(" "):
                                            n=ea.split("/")
                                            if n[1] == "NN":
                                                noun_box.append(n[0])
                                        json_object[f'{a}{cont_list[b]}{cont_list[c]}{cont_list[d]}']={'sentence':sen_list[cnt],'noun_phrase':noun_p,'nouns':noun_box}
                                        for noun in noun_p:
                                            if noun in list(noun_list.keys()):
                                                noun_list[str(noun)].append(f'{a}{cont_list[b]}{cont_list[c]}{cont_list[d]}')    
                                            else:
                                                noun_list[str(noun)]=[f'{a}{cont_list[b]}{cont_list[c]}{cont_list[d]}']
                                        for nn in noun_box:
                                            if nn in list(noun_list.keys()):
                                                noun_list[str(nn)].append(f'{a}{cont_list[b]}{cont_list[c]}{cont_list[d]}')    
                                            else:
                                                noun_list[str(nn)]=[f'{a}{cont_list[b]}{cont_list[c]}{cont_list[d]}']
                                        if json_object[f'{a}{cont_list[b]}{cont_list[c]}{cont_list[d]}']=='ZNNN':
                                            a="Y"
                                            b=0
                                            c=0
                                            d=0
                                        if json_object[f'{a}{cont_list[b]}{cont_list[c]}{cont_list[d]}']=='YNNN':
                                            a="X"
                                            b=0
                                            c=0
                                            d=0                                   
                                        if cnt == key_cnt-1:
                                            print('done')
                                            go=False
                                            print(list(json_object.keys())[-1])
                                        else:
                                            cnt+=1
    return json_object,noun_list
def find_query(query,sen,nouns):
    blob_f = TextBlob(query)
    noun_box={}
    noun_list=[]
    sen_box=[]
    for ea in blob_f.parse().split(" "):
        n=ea.split("/")
        if n[1] == "NN":
            noun_list.append(n[0])
    nouns_l=list(nouns.keys())
    for nn in nouns_l:
        for nl in noun_list:
            if nl in nn:
                if nl in noun_box:
                    for ea_n in nouns[nn]:
                        noun_box[str(nl)].append(ea_n)    
                else:
                    noun_box[str(nl)]=[]         
                    for ea_n in nouns[nn]:
                        noun_box[str(nl)].append(ea_n)
    for ea in noun_box.values():
        for vals in ea:
            sen_box.append(sen[vals]['sentence'])
    return noun_box,sen_box

with gr.Blocks() as app:
    inp = gr.Textbox(label="Paste Text",value=text,lines=10)
    btn = gr.Button("Load Document")
    with gr.Row():
        query=gr.Textbox(label="Search query")
        search_btn=gr.Button("Search")
        steps=gr.Number(value=1)
    out_box=gr.Textbox(label="Results")
    sen_box=gr.Textbox(label="Sentences")
    with gr.Row():
        with gr.Column(scale=2):
            sen=gr.JSON(label="Sentences")
        with gr.Column(scale=1):
            nouns=gr.JSON(label="Nouns")
    search_btn.click(find_query,[query,sen,nouns],[out_box,sen_box])
    btn.click(get_nouns,[inp,steps],[sen,nouns])
app.launch()