eadx oongaboongahacker commited on
Commit
cb69605
·
0 Parent(s):

Duplicate from oongaboongahacker/Gemini-Nano

Browse files

Co-authored-by: oonga <oongaboongahacker@users.noreply.huggingface.co>

Files changed (3) hide show
  1. .gitattributes +35 -0
  2. README.md +142 -0
  3. weights.bin +3 -0
.gitattributes ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tar filter=lfs diff=lfs merge=lfs -text
29
+ *.tflite filter=lfs diff=lfs merge=lfs -text
30
+ *.tgz filter=lfs diff=lfs merge=lfs -text
31
+ *.wasm filter=lfs diff=lfs merge=lfs -text
32
+ *.xz filter=lfs diff=lfs merge=lfs -text
33
+ *.zip filter=lfs diff=lfs merge=lfs -text
34
+ *.zst filter=lfs diff=lfs merge=lfs -text
35
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,142 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # GEMINI NANO EXTRACTED FROM CHROME CANARY VERSION 128.0.6557.0
2
+
3
+
4
+ If you have the particular version(>128), you can access the model here on windows:
5
+
6
+ C:\Users\USERNAME\AppData\Local\Google\Chrome SxS\User Data\OptGuideOnDeviceModel\[version]\weights.bin
7
+
8
+ You can signup for the built-in AI program here: https://developer.chrome.com/docs/ai/built-in
9
+
10
+ The model seems to be of the TFLite model format with the following architecture:
11
+
12
+ ![image/png](https://cdn-uploads.huggingface.co/production/uploads/6579ab1a95e559712cc09eae/ijTSh0CXcYkp5AqMJkf0V.png)
13
+
14
+
15
+ ## Run the model using Mediapipe:
16
+ Instructions from here: https://github.com/google-ai-edge/mediapipe-samples/tree/main/examples/llm_inference/js
17
+
18
+ In a directory, make two files:
19
+
20
+ `index.html`:
21
+ ```html
22
+ <!-- Copyright 2024 The MediaPipe Authors.
23
+
24
+ Licensed under the Apache License, Version 2.0 (the "License");
25
+ you may not use this file except in compliance with the License.
26
+ You may obtain a copy of the License at
27
+
28
+ http://www.apache.org/licenses/LICENSE-2.0
29
+
30
+ Unless required by applicable law or agreed to in writing, software
31
+ distributed under the License is distributed on an "AS IS" BASIS,
32
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
33
+ See the License for the specific language governing permissions and
34
+ limitations under the License. -->
35
+
36
+ <!doctype html>
37
+ <html lang="en">
38
+ <head>
39
+ <title>LLM Inference Web Demo</title>
40
+ </head>
41
+ <body>
42
+ Input:<br />
43
+ <textarea id="input" style="height: 300px; width: 600px"></textarea><br />
44
+ <input type="button" id="submit" value="Get Response" disabled /><br />
45
+ <br />
46
+ Result:<br />
47
+ <textarea id="output" style="height: 300px; width: 600px"></textarea>
48
+ <script type="module" src="index.js"></script>
49
+ </body>
50
+ </html>
51
+ ```
52
+
53
+ `index.js`(Replace line no. 23 to the path to the .bin file):
54
+ ```js
55
+ // Copyright 2024 The MediaPipe Authors.
56
+
57
+ // Licensed under the Apache License, Version 2.0 (the "License");
58
+ // you may not use this file except in compliance with the License.
59
+ // You may obtain a copy of the License at
60
+
61
+ // http://www.apache.org/licenses/LICENSE-2.0
62
+
63
+ // Unless required by applicable law or agreed to in writing, software
64
+ // distributed under the License is distributed on an "AS IS" BASIS,
65
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
66
+ // See the License for the specific language governing permissions and
67
+ // limitations under the License.
68
+
69
+ // ---------------------------------------------------------------------------------------- //
70
+
71
+ import {FilesetResolver, LlmInference} from 'https://cdn.jsdelivr.net/npm/@mediapipe/tasks-genai';
72
+
73
+ const input = document.getElementById('input');
74
+ const output = document.getElementById('output');
75
+ const submit = document.getElementById('submit');
76
+
77
+ const modelFileName = 'weights.bin'; /* PATH TO MODEL .bin */
78
+
79
+ /**
80
+ * Display newly generated partial results to the output text box.
81
+ */
82
+ function displayPartialResults(partialResults, complete) {
83
+ output.textContent += partialResults;
84
+
85
+ if (complete) {
86
+ if (!output.textContent) {
87
+ output.textContent = 'Result is empty';
88
+ }
89
+ submit.disabled = false;
90
+ }
91
+ }
92
+
93
+ /**
94
+ * Main function to run LLM Inference.
95
+ */
96
+ async function runDemo() {
97
+ const genaiFileset = await FilesetResolver.forGenAiTasks(
98
+ 'https://cdn.jsdelivr.net/npm/@mediapipe/tasks-genai/wasm');
99
+ let llmInference;
100
+
101
+ submit.onclick = () => {
102
+ output.textContent = '';
103
+ submit.disabled = true;
104
+ llmInference.generateResponse(input.value, displayPartialResults);
105
+ };
106
+
107
+ submit.value = 'Loading the model...'
108
+ LlmInference
109
+ .createFromOptions(genaiFileset, {
110
+ baseOptions: {modelAssetPath: modelFileName},
111
+ // maxTokens: 512, // The maximum number of tokens (input tokens + output
112
+ // // tokens) the model handles.
113
+ // randomSeed: 1, // The random seed used during text generation.
114
+ // topK: 1, // The number of tokens the model considers at each step of
115
+ // // generation. Limits predictions to the top k most-probable
116
+ // // tokens. Setting randomSeed is required for this to make
117
+ // // effects.
118
+ // temperature:
119
+ // 1.0, // The amount of randomness introduced during generation.
120
+ // // Setting randomSeed is required for this to make effects.
121
+ })
122
+ .then(llm => {
123
+ llmInference = llm;
124
+ submit.disabled = false;
125
+ submit.value = 'Get Response'
126
+ })
127
+ .catch(() => {
128
+ alert('Failed to initialize the task.');
129
+ });
130
+ }
131
+
132
+ runDemo();
133
+ ```
134
+ ## Run using:
135
+ `python3 -m http.server 8000` in the same directory (or python -m SimpleHTTPServer 8000 for older python versions).
136
+
137
+ Finally,
138
+
139
+ `Open localhost:8000 in Chrome`
140
+
141
+ ## License
142
+ I dont own shit. Just extracted the model weights stored as a .bin file. https://policies.google.com/terms/generative-ai/use-policy
weights.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bad5926061c8942fbed91b42266c76ac4d5b7e79d352a205466bf29950af0191
3
+ size 1782710272