@@ -15,7 +15,7 @@ const fetchPartialFile = async (url: string, start: number, end: number) => {
1515}
1616
1717describe ( 'gguf' , ( ) => {
18- it (
18+ test (
1919 'Llama-2-7b-Chat-GGUF ' ,
2020 async ( ) => {
2121 const file = await fetchPartialFile (
@@ -68,4 +68,114 @@ describe('gguf', () => {
6868 } ,
6969 1000 * 30 ,
7070 )
71+
72+ test (
73+ 'Nous-Capybara-7B-v1.9-GGUF' ,
74+ async ( ) => {
75+ const file = await fetchPartialFile (
76+ 'https://huggingface.co/TheBloke/Nous-Capybara-7B-v1.9-GGUF/resolve/main/nous-capybara-7b-v1.9.Q4_K_M.gguf' ,
77+ 0 ,
78+ // 10mb
79+ 1024 * 1024 * 10 ,
80+ )
81+
82+ const fileName = path . join (
83+ __dirname ,
84+ 'models' ,
85+ 'nous-capybara-7b-v1.9.Q4_K_M.gguf' ,
86+ )
87+
88+ await writeFile ( fileName , Buffer . from ( file ) )
89+
90+ const { error, metadata } = await gguf ( fileName )
91+
92+ expect ( error ) . toBe ( undefined )
93+ expect ( metadata ) . not . toBe ( undefined )
94+ if ( ! metadata ) return // for types
95+
96+ expect ( metadata . general . architecture ) . toBe ( 'llama' )
97+ if ( ! isLlamaMetadata ( metadata ) ) return // for types
98+
99+ expect ( metadata . llama ) . toBeTruthy ( )
100+
101+ expect ( metadata ) . toEqual ( {
102+ general : {
103+ architecture : 'llama' ,
104+ file_type : 'MOSTLY_Q4_K_M' ,
105+ name : 'nousresearch_nous-capybara-7b-v1.9' ,
106+ quantization_version : 2 ,
107+ } ,
108+ llama : {
109+ attention : {
110+ head_count : 32 ,
111+ head_count_kv : 8 ,
112+ layer_norm_rms_epsilon : 0.000009999999747378752 ,
113+ } ,
114+ context_length : 32768 ,
115+ embedding_length : 4096 ,
116+ feed_forward_length : 14336 ,
117+ rope : {
118+ dimension_count : 128 ,
119+ freq_base : 10000 ,
120+ } ,
121+ } ,
122+ } )
123+ } ,
124+ 1000 * 30 ,
125+ )
126+
127+ test (
128+ 'Xwin-MLewd-7B-V0.2-GGUF' ,
129+ async ( ) => {
130+ const file = await fetchPartialFile (
131+ 'https://huggingface.co/TheBloke/Xwin-MLewd-7B-V0.2-GGUF/resolve/main/xwin-mlewd-7b-v0.2.Q4_K_M.gguf' ,
132+ 0 ,
133+ // 10mb
134+ 1024 * 1024 * 10 ,
135+ )
136+
137+ const fileName = path . join (
138+ __dirname ,
139+ 'models' ,
140+ 'xwin-mlewd-7b-v0.2.Q4_K_M.gguf' ,
141+ )
142+
143+ await writeFile ( fileName , Buffer . from ( file ) )
144+
145+ const { error, metadata } = await gguf ( fileName )
146+
147+ expect ( error ) . toBe ( undefined )
148+ expect ( metadata ) . not . toBe ( undefined )
149+ if ( ! metadata ) return // for types
150+
151+ expect ( metadata . general . architecture ) . toBe ( 'llama' )
152+ if ( ! isLlamaMetadata ( metadata ) ) return // for types
153+
154+ expect ( metadata . llama ) . toBeTruthy ( )
155+
156+ expect ( metadata ) . toEqual ( {
157+ general : {
158+ architecture : 'llama' ,
159+ file_type : 'MOSTLY_Q4_K_M' ,
160+ name : 'LLaMA v2' ,
161+ quantization_version : 2 ,
162+ } ,
163+ llama : {
164+ attention : {
165+ head_count : 32 ,
166+ head_count_kv : 32 ,
167+ layer_norm_rms_epsilon : 0.000009999999747378752 ,
168+ } ,
169+ context_length : 4096 ,
170+ embedding_length : 4096 ,
171+ feed_forward_length : 11008 ,
172+ rope : {
173+ dimension_count : 128 ,
174+ freq_base : 10000 ,
175+ } ,
176+ } ,
177+ } )
178+ } ,
179+ 1000 * 30 ,
180+ )
71181} )
0 commit comments