-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
89 lines (84 loc) · 2.67 KB
/
index.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>hyllama gguf file parser</title>
<style>
#dropzone {
position: absolute;
bottom: 10px;
box-sizing: border-box;
top: 10px;
left: 10px;
right: 10px;
border: 2px dashed #08e;
border-radius: 10px;
padding: 10px;
display: flex;
color: #444;
font-family: sans-serif;
font-size: 20px;
overflow-y: auto;
}
code {
font-size: 12px;
white-space: pre-wrap;
}
.over {
background-color: lightblue;
}
</style>
</head>
<body>
<div id="dropzone">Drop GGUF model file here</div>
<script type="module">
import { ggufMetadata } from './src/hyllama.js'
const dropZone = document.getElementById('dropzone')
dropZone.addEventListener('dragover', e => {
e.preventDefault()
e.dataTransfer.dropEffect = 'copy'
dropZone.classList.add('over')
})
dropZone.addEventListener('dragleave', () => {
dropZone.classList.remove('over')
})
dropZone.addEventListener('drop', e => {
e.preventDefault() // prevent dropped file from being "downloaded"
dropZone.classList.remove('over')
const files = e.dataTransfer.files
if (files.length > 0) {
const file = files[0]
const reader = new FileReader()
reader.onload = async (e) => {
const arrayBuffer = e.target.result
const { metadata, tensorInfos } = ggufMetadata(arrayBuffer)
console.log(metadata, tensorInfos)
// these are large and of questionable value
delete metadata['tokenizer.ggml.tokens']
delete metadata['tokenizer.ggml.scores']
delete metadata['tokenizer.ggml.token_type']
// display metadata
let text = 'filename: ' + file.name
for (const key in metadata) {
const value = metadata[key]
text += `\n${key}: ${value}`
}
// display tensorInfos
for (const tensorInfo of tensorInfos) {
text += `\ntensor ${tensorInfo.name} (${tensorInfo.shape.join('x')})`
}
const code = document.createElement('code')
code.innerText = text
dropZone.innerHTML = ''
dropZone.appendChild(code)
}
reader.onerror = e => {
console.error('Error reading file', e)
dropZone.innerText = `Error reading file\n${e.target.error}`
}
reader.readAsArrayBuffer(file)
}
})
</script>
</body>
</html>