Skip to content

Commit

Permalink
Update demo html to display tensor info
Browse files Browse the repository at this point in the history
  • Loading branch information
platypii committed Mar 9, 2024
1 parent 3354599 commit 730c588
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 13 deletions.
22 changes: 16 additions & 6 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@
border-radius: 10px;
padding: 10px;
display: flex;
align-items: center;
justify-content: center;
color: #444;
font-family: sans-serif;
font-size: 20px;
overflow-y: auto;
}
code {
font-size: 12px;
white-space: pre-wrap;
}
.over {
background-color: lightblue;
}
Expand Down Expand Up @@ -54,18 +56,26 @@
const reader = new FileReader()
reader.onload = async (e) => {
const arrayBuffer = e.target.result
const metadata = ggufMetadata(arrayBuffer)
console.log(metadata)
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
dropZone.innerText = file.name
let text = 'filename: ' + file.name
for (const key in metadata) {
const value = metadata[key]
dropZone.innerText += `\n${key}: ${value}`
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)
Expand Down
14 changes: 7 additions & 7 deletions src/hyllama.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
* @returns metadata object
*/
export declare function ggufMetadata(arrayBuffer: ArrayBuffer): {
metadata: Record<string, any>;
metadata: Record<string, any>
tensorInfos: {
name: string;
nDims: number;
shape: bigint[];
type: number;
offset: bigint;
}[];
name: string
nDims: number
shape: bigint[]
type: number
offset: bigint
}[]
}

0 comments on commit 730c588

Please sign in to comment.