sanmonga22 commited on
Commit
21f379c
Β·
verified Β·
1 Parent(s): 16ee68b

Upload folder using huggingface_hub

Browse files
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* 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
 
 
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
36
+ v81/tokenizer.json filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: other
3
+ license_name: nvidia-open-model-license
4
+ base_model: nvidia/llama-3.2-nv-embedqa-1b-v2
5
+ tags: [qhexrt, hexagon, npu, qualcomm, embedding, on-device, v81, snapdragon]
6
+ library_name: qhexrt
7
+ pipeline_tag: feature-extraction
8
+ ---
9
+
10
+ # NV-EmbedQA-1B β†’ Hexagon NPU (QHexRT, v81)
11
+
12
+ On-device text-embedding bundle of **[nvidia/llama-3.2-nv-embedqa-1b-v2](https://huggingface.co/nvidia/llama-3.2-nv-embedqa-1b-v2)**
13
+ for the **Qualcomm Hexagon v81 NPU** (SM8850 / Snapdragon 8 Elite Gen-class), runnable with the
14
+ [QHexRT](https://github.com/RunanywhereAI) C++ runtime. **No Python in the hot path.**
15
+
16
+ The model is a `LlamaBidirectionalModel` (rotary Llama-3.2-1B layers, **full/bidirectional** attention,
17
+ hidden 2048, 16 layers, 32 query / 8 KV heads, head_dim 64) followed by **avg-pool over valid tokens + L2**.
18
+ It produces a **2048-d** sentence embedding.
19
+
20
+ ## Device validation (v81, SM8850)
21
+ | metric | value |
22
+ |---|---|
23
+ | **device-vs-HF cosine** (8-tok query) | **1.00000** |
24
+ | **device-vs-HF cosine** (8-tok doc) | **1.00000** |
25
+ | **device-vs-HF cosine** (33-tok input) | **1.00000** |
26
+ | retrieval cos(q,d): device / HF | 0.83613 / 0.83598 |
27
+ | encoder latency | ~36 ms |
28
+
29
+ The on-device embedding is **bit-faithful to the HuggingFace reference** across input lengths (cosine β‰₯ 0.9999).
30
+
31
+ ## What's inside (`v81/`)
32
+ - `nvembedqa_enc.bin` β€” the bidirectional Llama encoder as a v81 fp16 QNN context binary (graph
33
+ `nvembedqa_enc_f16`; host-computed RoPE fed as inputs, **no in-graph rotary Gather**; seq 64).
34
+ - `nvembedqa_embed_f16.bin` β€” the token-embedding table (fp16).
35
+ - `tokenizer.json`, `tokenizer_config.json` β€” the Llama-3 BPE tokenizer.
36
+ - `nv-embedqa-1b.json` β€” the QHexRT manifest (host-op `llama_embed`: tokenize β†’ embed β†’ llama3-scaled RoPE
37
+ (factor 32) β†’ bidirectional padding mask β†’ encoder graph β†’ avg-pool β†’ L2).
38
+
39
+ ## Run
40
+ ```bash
41
+ adb push v81 /data/local/tmp/wq/nvembed
42
+ adb shell "cd /data/local/tmp/wq && LD_LIBRARY_PATH=. \
43
+ QHX_EMB_QUERY_PREFIX= QHX_EMB_DOC_PREFIX= \
44
+ ./qhx_embed nvembed/nv-embedqa-1b.json libQnnHtp.so libQnnSystem.so nvembed \
45
+ 'What is the capital of France?' 'Paris is the capital of France.'"
46
+ # -> QUERY/DOC 2048-d L2-normalized vectors + cosine(query, document)
47
+ ```
48
+ Embeddings are computed over **raw text** (no task prefix) β€” set the prefix env vars to empty as shown.
49
+
50
+ ## Arch pinning
51
+ A QNN context binary is **arch- and QAIRT-version-pinned**: this `v81` bundle (QAIRT 2.47, soc_model 87) loads
52
+ only on a v81 device whose runtime libs are β‰₯ the compile QAIRT. It will **not** load on v79/v83.
v81/nv-embedqa-1b.json ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "schema_version": 1,
3
+ "_comment": "NV-EmbedQA-1B (LlamaBidirectional + avg-pool) on Hexagon v81. Host-rope bidirectional encoder graph (no in-graph Gather) + llama_embed host-op (embed + llama3 rope factor 32 + bidirectional mask + avg-pool + L2). Encoder S=64.",
4
+ "model": {
5
+ "name": "nv-embedqa-1b",
6
+ "family": "embedding",
7
+ "dsp_arch": "v81",
8
+ "tokenizer_pre": "llama3"
9
+ },
10
+ "params": {
11
+ "hidden": 2048,
12
+ "vocab": 128256,
13
+ "n_layers": 16,
14
+ "head_dim": 64,
15
+ "max_ctx": 64,
16
+ "eos_token_id": 128001
17
+ },
18
+ "artifacts": {
19
+ "contexts": {
20
+ "encoder": {
21
+ "bin": "nvembedqa_enc.bin"
22
+ }
23
+ },
24
+ "embed": "nvembedqa_embed_f16.bin",
25
+ "tokenizer": "tokenizer.json"
26
+ },
27
+ "plan": {
28
+ "steps": [
29
+ {
30
+ "host": "llama_embed",
31
+ "params": {
32
+ "encoder": "nvembedqa_enc_f16",
33
+ "rope_factor": 32.0,
34
+ "neg": -50000
35
+ }
36
+ }
37
+ ]
38
+ }
39
+ }
v81/nvembedqa_embed_f16.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d0f26c68ed40afd43c2510ef455064d3b4738765b5ea39d2cf48648b5e245cf6
3
+ size 525336576
v81/nvembedqa_enc.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:469c2414679694612dc48406800a4572cb9994fe3f48938a94904bb3ed7ec486
3
+ size 1950478336
v81/tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6b9e4e7fb171f92fd137b777cc2714bf87d11576700a1dcd7a399e7bbe39537b
3
+ size 17209920
v81/tokenizer_config.json ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "backend": "tokenizers",
3
+ "bos_token": "<|begin_of_text|>",
4
+ "clean_up_tokenization_spaces": true,
5
+ "eos_token": "<|end_of_text|>",
6
+ "is_local": false,
7
+ "local_files_only": false,
8
+ "model_input_names": [
9
+ "input_ids",
10
+ "attention_mask"
11
+ ],
12
+ "model_max_length": 131072,
13
+ "pad_token": "<|end_of_text|>",
14
+ "tokenizer_class": "TokenizersBackend"
15
+ }