kaamd commited on
Commit
6a48e45
·
verified ·
1 Parent(s): 5e7d520

Upload folder using huggingface_hub

Browse files
1_Pooling/config.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "word_embedding_dimension": 4096,
3
+ "pooling_mode_cls_token": false,
4
+ "pooling_mode_mean_tokens": false,
5
+ "pooling_mode_max_tokens": false,
6
+ "pooling_mode_mean_sqrt_len_tokens": false,
7
+ "pooling_mode_weightedmean_tokens": false,
8
+ "pooling_mode_lasttoken": true,
9
+ "include_prompt": true
10
+ }
2_SparseEmbedding/config.json ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "n_in": 4096,
3
+ "init_mean": 0.5,
4
+ "init_std": 0.01,
5
+ "temperature": 1.0,
6
+ "stretch": 0.1,
7
+ "eps": 1e-06
8
+ }
2_SparseEmbedding/pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:55820e46cd6fa739d6844a20567ecf18f7c969c484db91da09420188d9e6b862
3
+ size 18044
README.md ADDED
@@ -0,0 +1,882 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ tags:
3
+ - sentence-transformers
4
+ - sentence-similarity
5
+ - feature-extraction
6
+ - dense
7
+ - generated_from_trainer
8
+ - dataset_size:14166
9
+ - loss:SparseLoss
10
+ - loss:MultipleNegativesRankingLoss
11
+ widget:
12
+ - source_sentence: 'Instruct: Given a web search query, retrieve relevant passages
13
+ that answer the query
14
+
15
+ Query: Does borrowing from my 401(k) make sense in my specific circumstance?'
16
+ sentences:
17
+ - 'I''m not sure why you think that it matters that the distribution goes to an
18
+ S-Corp vs an individual tax payer. You seem to think it has any relevance to your
19
+ question, but it doesn''t. It only confuses your readers. The situation is like
20
+ this: LLC X is deriving income in State #2. It has two members (I and S) residents
21
+ of State #1. Members I and S pay all their taxes to State #1, and don''t pay taxes
22
+ to State #2. State #2 audited member I and that member now needs to pay back taxes
23
+ and penalties to State #2 on income derived from that State. Your question: Does
24
+ that mean that member S should be worried, since that member was essentially doing
25
+ the exact same thing as member I? My answer: Yes.'
26
+ - Interest rates are market driven. They tend to be based on the prime rate set
27
+ by the federal reserve bank because of the tremendous lending capacity of that
28
+ institution and that other loan originators will often fund their own lending
29
+ (at least in part) with fed loans. However, there is no mandatory link between
30
+ the federal reserve rate and the market rate. No law stipulates that rates cannot
31
+ rise or fall. They will rise and fall as lenders see necessary to use their capital.
32
+ Though a lender asking 10% interest might make no loans when others are willing
33
+ to lend for 9%. The only protection you have is that we are (mostly) economically
34
+ free. As a borrower, you are protected by the fact that there are many lenders.
35
+ Likewise, as a lender, because there are many borrowers. Stability is simply by
36
+ virtue of the fact that one market participant with inordinate pricing will find
37
+ fewer counterparties to transact.
38
+ - '"You''re getting great wisdom and options. Establishing your actionable path
39
+ will require the details that only you know, such as how much is actually in each
40
+ paycheck (and how much tax is withheld), how much do you spend each month (and
41
+ yearly expenses too), how much spending can you actually cut or replace, how comfortable
42
+ are you with considering (or not considering) unexpected/emergency spending. You
43
+ mentioned you were cash-poor, but only you know what your current account balances
44
+ are, which will affect your actions and priorities. Btw, interestingly, your ""increase
45
+ 401k contributions by 2% each year"" will need to end before hitting the $18K
46
+ contribution limit. I took some time and added the details you posted into a cash-flow
47
+ program to see your scenario over the next few years. There isn''t a ""401k loan""
48
+ activity in this program yet, so I build the scenario from other simple activities.
49
+ You seem financially minded enough to continue modeling on your own. I''m posting
50
+ the more difficult one for you (borrow from 401k), but you''ll have to input your
51
+ actual balances, paycheck and spending. My spending assumptions must be low, and
52
+ I entered $70K as ""take-home,"" so the model looks like you''ve got lots of cash.
53
+ If you choose to play with it, then consider modeling some other scenarios from
54
+ the advice in the other posts. Here''s the ""Borrow $6500 from 401k"" scenario
55
+ model at Whatll.Be: https://whatll.be/d1x1ndp26i/2 To me, it''s all about trying
56
+ the scenarios and see which one seems to work with all of the details. The trick
57
+ is knowing what scenarios to try, and how to model them. Full disclosure: I needed
58
+ to do similar planning, so I wrote Whatll.Be and I now share it with other people.
59
+ It''s in beta, so I''m testing it with scenarios like yours. (Notice most of the
60
+ extra activity occurs on 2018-Jan-01)"'
61
+ - source_sentence: 'Instruct: Given a web search query, retrieve relevant passages
62
+ that answer the query
63
+
64
+ Query: Finding a good small business CPA?'
65
+ sentences:
66
+ - I have had better experiences with accountants in smaller towns. It seems they
67
+ are used to working with small businesses and their reputation is very important
68
+ to them.
69
+ - '"It''s a scam. The cashier''s check will be forged. Craigslist has a warning
70
+ about it here (item #3). What kind of payment do you think is not fakable? Or
71
+ at least not likely to be used in scams? When on craigslist - deal only locally
72
+ and in person. You can ask to see the person''s ID if you''re being paid by check
73
+ When being paid by check, how can seeing his/her ID help? In case the check
74
+ isn''t cashable, I can find that person by keeping record of his/her ID? If
75
+ you''re paid by check, the payers details should be printed on the check. By checking
76
+ the ID you can verify that the details match (name/address), so you can find the
77
+ payer later. Of course the ID can be faked too, but there''s so much you can do
78
+ to protect yourself. You''ll get better protection (including verified escrow
79
+ service) by selling on eBay. Is being paid by cash the safest way currently, although
80
+ cash can be faked too, but it is the least common thing that is faked currently?
81
+ Do you recommend to first deposit the cash into a bank (so that let the bank
82
+ verify if the cash is faked), before delivering the good? For Craigslist, use
83
+ cash and meet locally. That rules out most scams as a seller. What payment methods
84
+ do you think are relatively safe currently? Then getting checks must be the
85
+ least favorite way of being paid. Do you think cash is better than money order
86
+ or cashier order? You should only accept cash. If it is a large transaction,
87
+ you can meet them at your bank, have them get cash, and you receive the cash from
88
+ the bank. Back to the quoted scam, how will they later manipulate me? Are they
89
+ interested in my stuffs on moving sale, or in my money? They will probably ""accidentally""
90
+ overpay you and ask for a refund of some portion of the overpayment. In that case
91
+ you will be out the entire amount that you send back to them and possibly some
92
+ fees from your bank for cashing a bad check."'
93
+ - '"Putting them on line 10 is best suited for your situation. According to Quickbooks: Commissions
94
+ and Fees (Line 10) Commissions/fees paid to nonemployees to generate revenue (e.g.
95
+ agent fees). It seems like this website you are using falls under the term ""nonemployees""."'
96
+ - source_sentence: 'Instruct: Given a web search query, retrieve relevant passages
97
+ that answer the query
98
+
99
+ Query: Are Investment Research websites worth their premiums?'
100
+ sentences:
101
+ - Anyone who claims they can consistently beat the market and asks you to pay them
102
+ to tell you how is a liar. This cannot be done, as the market adjusts itself.
103
+ There's nothing they could possibly learn that analysts and institutional investors
104
+ don't already know. They earn their money through the subscription fees, not through
105
+ capital gains on their beat-the-market suggestions, that means that they don't
106
+ have to rely on themselves to earn money, they only need you to rely on them.
107
+ They have to provide proof because they cannot lie in advertisements, but if you
108
+ read carefully, there are many small letters and disclaimers that basically remove
109
+ any liability from them by saying that they don't take responsibility for anything
110
+ and don't guarantee anything.
111
+ - '"I don''t see EWQ6 in any of your links, so I can''t say for certain, but when
112
+ you buy an option contract on a future, the option will be for a specific future
113
+ (and strike). So the page you''re looking at may be for options on E-mini S&P
114
+ 500 futures in general, and when you actually purchase one through your broker,
115
+ you pick a specific expiry (which will be based on the ""prompt"" future, meaning
116
+ the next future that expires after the option) and strike. UPDATE: Based on this
117
+ page mirror, the option EWQ7 is an option on the ESU7 (SEP 2017) future. The
118
+ next 3 monthly options use ESZ7 as the underlier, which confirms that they use
119
+ the next prompt future as the underlier."'
120
+ - There are a few factors at play here. Depending on the bank that has offered you
121
+ the card there are different types of overdraft protection that may have been
122
+ set up. Typically, if they attempt to run the card with no money, if one of these
123
+ is in play, you will be spared any overdraft fees by the transaction charging
124
+ to a designated overdraft account, usually savings, or by the transaction failing
125
+ due to insufficient funds. If you know the transaction went through, and you
126
+ know there were not enough funds in the account to cover the transactions, then
127
+ you have a few options. If you have overdraft protection that auto charges insufficient
128
+ funds charges to a separate account, then you have nothing to worry about. If
129
+ you do not, most banks offer a grace period where you have until the end of the
130
+ day to zero out your account, that is to say pay the overdraft amount and bring
131
+ your balance to at least $0. If this is a charge that occurred in the past, and
132
+ you have already been charged an overdraft fee, there may still be hope. I cannot
133
+ speak for all banks, but I know that Chase Bank offers a once per year overdraft
134
+ forgiveness, where they will get rid of the charges if you agree to bring the
135
+ account out of the negative. There is a chance other banks will do the same if
136
+ you call their customer service.
137
+ - source_sentence: 'Instruct: Given a web search query, retrieve relevant passages
138
+ that answer the query
139
+
140
+ Query: Ballpark salary equivalent today of “healthcare benefits” in the US?'
141
+ sentences:
142
+ - While in the interview stage you need one good outfit. Take care of them and they
143
+ will see you through this stage of the process. Shoes, ties, shirt, and a suit
144
+ can all be purchased on sale. The fact that you have months before graduation
145
+ give you time to purchase them when there is a sale. Off-the-rack is good enough
146
+ for a suit for this stage of your life. There is no need to go custom made when
147
+ you are just starting out. In fact you may find you never need more than one or
148
+ two suits, and they never need to be custom made.
149
+ - Fiduciary They are obligated by the rules of the exchanges they are listed with.
150
+ Furthermore, there is a strong chance that people running the company also have
151
+ stock, so it personally benefits them to create higher prices. Finally, maybe
152
+ they don't care about the prices directly, but by being a good company with a
153
+ good product or service, they are desirable and that is expressed as a higher
154
+ stock price. Not every action is because it will raise the stock price, but because
155
+ it is good for business which happens to make the stock more valuable.
156
+ - 'There is some magic involved in that calculation, because what health insurance
157
+ is worth to you is not necessarily the same it is worth for the employer. Two
158
+ examples that illustrate the extreme ends of the spectrum: let''s say you or a
159
+ family member have a chronic or a serious illness, especially if it is a preexisting
160
+ condition - for instance, cancer. In that case, health insurance can be worth
161
+ literally millions of dollars to you. Even if you are a diabetic, the value of
162
+ health insurance can be substantial. Sometimes, it could even make financial sense
163
+ in that case to accept a very low-paying job. On the other extreme of the scale,
164
+ if you are very young and healthy, many people decide to forego insurance. In
165
+ that case, the value of health insurance can be as little as the penalty (usually,
166
+ 2% of your taxable income, I believe).'
167
+ - source_sentence: 'Instruct: Given a web search query, retrieve relevant passages
168
+ that answer the query
169
+
170
+ Query: I am under 18 years old, in the US, my parents have terrible credit, how
171
+ can I take out a loan?'
172
+ sentences:
173
+ - What about web-hosting fees? Cost of Internet service? Cost of computer equipment
174
+ to do the work? Amortized cost of development? Time for support calls/email? Phone
175
+ service used for sales? Advertising/marketing expenses? Look hard--I bet there
176
+ are some costs.
177
+ - 'In the equity markets, the P/E is usually somewhere around 15. The P/E can be
178
+ viewed as the inverse of the rate of a perpetuity. Since the average is 15, and
179
+ the E/P of that would be 6.7%, r should be 6.7% on average. If your business is
180
+ growing, the growth rate can be incorporated like so: As you can see, a high g
181
+ would make the price negative, in essence the seller should actually pay someone
182
+ to take the business, but in reality, r is determined from the p and an estimated
183
+ g. For a business of any growth rate, it''s best to compare the multiple to the
184
+ market, so for the average business in the market with your business''s growth
185
+ rate and industry, that P/E would be best applied to your company''s income.'
186
+ - Depending on the state this might not be possible. Loans are considered contracts,
187
+ and various states regulate how minors may enter into them. For example, in the
188
+ state of Oregon, a minor may NOT enter into a contract without their parent being
189
+ on the contract as well. So you are forced to wait until you turn 18. At that
190
+ time you won't have a credit history, and to lenders that often is worse than
191
+ having bad credit. I can't help with the car (other than to recommend you buy
192
+ a junker for $500-$1,000 and just live with it for now), but you could certainly
193
+ get a secured credit card or line of credit from your local bank. The way they
194
+ are arranged is, you make a deposit of an amount of your choosing (generally at
195
+ least $200 for credit cards, and $1,000 for lines of credit), and receive a revolving
196
+ line with a limit of that same amount. As you use and pay on this loan, it will
197
+ be reported in your credit history. If you start that now, by the time you turn
198
+ 18 you will have much better options for purchasing vehicles.
199
+ pipeline_tag: sentence-similarity
200
+ library_name: sentence-transformers
201
+ ---
202
+
203
+ # SentenceTransformer
204
+
205
+ This is a [sentence-transformers](https://www.SBERT.net) model trained on the fiqa dataset. It maps sentences & paragraphs to a 4096-dimensional dense vector space and can be used for semantic textual similarity, semantic search, paraphrase mining, text classification, clustering, and more.
206
+
207
+ ## Model Details
208
+
209
+ ### Model Description
210
+ - **Model Type:** Sentence Transformer
211
+ <!-- - **Base model:** [Unknown](https://huggingface.co/unknown) -->
212
+ - **Maximum Sequence Length:** 32768 tokens
213
+ - **Output Dimensionality:** 4096 dimensions
214
+ - **Similarity Function:** Cosine Similarity
215
+ - **Training Dataset:**
216
+ - fiqa
217
+ <!-- - **Language:** Unknown -->
218
+ <!-- - **License:** Unknown -->
219
+
220
+ ### Model Sources
221
+
222
+ - **Documentation:** [Sentence Transformers Documentation](https://sbert.net)
223
+ - **Repository:** [Sentence Transformers on GitHub](https://github.com/UKPLab/sentence-transformers)
224
+ - **Hugging Face:** [Sentence Transformers on Hugging Face](https://huggingface.co/models?library=sentence-transformers)
225
+
226
+ ### Full Model Architecture
227
+
228
+ ```
229
+ SentenceTransformer(
230
+ (0): Transformer({'max_seq_length': 32768, 'do_lower_case': False, 'architecture': 'MistralModel'})
231
+ (1): Pooling({'word_embedding_dimension': 4096, 'pooling_mode_cls_token': False, 'pooling_mode_mean_tokens': False, 'pooling_mode_max_tokens': False, 'pooling_mode_mean_sqrt_len_tokens': False, 'pooling_mode_weightedmean_tokens': False, 'pooling_mode_lasttoken': True, 'include_prompt': True})
232
+ (2): SparseEmbedding(
233
+ (sparsifyer): ZeroNeuron(in_features=4096, out_features=4096)
234
+ )
235
+ )
236
+ ```
237
+
238
+ ## Usage
239
+
240
+ ### Direct Usage (Sentence Transformers)
241
+
242
+ First install the Sentence Transformers library:
243
+
244
+ ```bash
245
+ pip install -U sentence-transformers
246
+ ```
247
+
248
+ Then you can load this model and run inference.
249
+ ```python
250
+ from sentence_transformers import SentenceTransformer
251
+
252
+ # Download from the 🤗 Hub
253
+ model = SentenceTransformer("sentence_transformers_model_id")
254
+ # Run inference
255
+ sentences = [
256
+ 'Instruct: Given a web search query, retrieve relevant passages that answer the query\nQuery: I am under 18 years old, in the US, my parents have terrible credit, how can I take out a loan?',
257
+ "Depending on the state this might not be possible. Loans are considered contracts, and various states regulate how minors may enter into them. For example, in the state of Oregon, a minor may NOT enter into a contract without their parent being on the contract as well. So you are forced to wait until you turn 18. At that time you won't have a credit history, and to lenders that often is worse than having bad credit. I can't help with the car (other than to recommend you buy a junker for $500-$1,000 and just live with it for now), but you could certainly get a secured credit card or line of credit from your local bank. The way they are arranged is, you make a deposit of an amount of your choosing (generally at least $200 for credit cards, and $1,000 for lines of credit), and receive a revolving line with a limit of that same amount. As you use and pay on this loan, it will be reported in your credit history. If you start that now, by the time you turn 18 you will have much better options for purchasing vehicles.",
258
+ "In the equity markets, the P/E is usually somewhere around 15. The P/E can be viewed as the inverse of the rate of a perpetuity. Since the average is 15, and the E/P of that would be 6.7%, r should be 6.7% on average. If your business is growing, the growth rate can be incorporated like so: As you can see, a high g would make the price negative, in essence the seller should actually pay someone to take the business, but in reality, r is determined from the p and an estimated g. For a business of any growth rate, it's best to compare the multiple to the market, so for the average business in the market with your business's growth rate and industry, that P/E would be best applied to your company's income.",
259
+ ]
260
+ embeddings = model.encode(sentences)
261
+ print(embeddings.shape)
262
+ # [3, 4096]
263
+
264
+ # Get the similarity scores for the embeddings
265
+ similarities = model.similarity(embeddings, embeddings)
266
+ print(similarities)
267
+ # tensor([[1.0000, 0.6277, 0.2807],
268
+ # [0.6277, 1.0000, 0.2775],
269
+ # [0.2807, 0.2775, 1.0000]])
270
+ ```
271
+
272
+ <!--
273
+ ### Direct Usage (Transformers)
274
+
275
+ <details><summary>Click to see the direct usage in Transformers</summary>
276
+
277
+ </details>
278
+ -->
279
+
280
+ <!--
281
+ ### Downstream Usage (Sentence Transformers)
282
+
283
+ You can finetune this model on your own dataset.
284
+
285
+ <details><summary>Click to expand</summary>
286
+
287
+ </details>
288
+ -->
289
+
290
+ <!--
291
+ ### Out-of-Scope Use
292
+
293
+ *List how the model may foreseeably be misused and address what users ought not to do with the model.*
294
+ -->
295
+
296
+ <!--
297
+ ## Bias, Risks and Limitations
298
+
299
+ *What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model.*
300
+ -->
301
+
302
+ <!--
303
+ ### Recommendations
304
+
305
+ *What are recommendations with respect to the foreseeable issues? For example, filtering explicit content.*
306
+ -->
307
+
308
+ ## Training Details
309
+
310
+ ### Training Dataset
311
+
312
+ #### fiqa
313
+
314
+ * Dataset: fiqa
315
+ * Size: 14,166 training samples
316
+ * Columns: <code>anchor</code> and <code>positive</code>
317
+ * Approximate statistics based on the first 1000 samples:
318
+ | | anchor | positive |
319
+ |:--------|:-----------------------------------------------------------------------------------|:-------------------------------------------------------------------------------------|
320
+ | type | string | string |
321
+ | details | <ul><li>min: 24 tokens</li><li>mean: 36.38 tokens</li><li>max: 62 tokens</li></ul> | <ul><li>min: 2 tokens</li><li>mean: 223.61 tokens</li><li>max: 1683 tokens</li></ul> |
322
+ * Samples:
323
+ | anchor | positive |
324
+ |:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
325
+ | <code>Instruct: Given a web search query, retrieve relevant passages that answer the query<br>Query: What is considered a business expense on a business trip?</code> | <code>The IRS Guidance pertaining to the subject. In general the best I can say is your business expense may be deductible. But it depends on the circumstances and what it is you want to deduct. Travel Taxpayers who travel away from home on business may deduct related expenses, including the cost of reaching their destination, the cost of lodging and meals and other ordinary and necessary expenses. Taxpayers are considered “traveling away from home” if their duties require them to be away from home substantially longer than an ordinary day’s work and they need to sleep or rest to meet the demands of their work. The actual cost of meals and incidental expenses may be deducted or the taxpayer may use a standard meal allowance and reduced record keeping requirements. Regardless of the method used, meal deductions are generally limited to 50 percent as stated earlier. Only actual costs for lodging may be claimed as an expense and receipts must be kept for documentation. ...</code> |
326
+ | <code>Instruct: Given a web search query, retrieve relevant passages that answer the query<br>Query: Business Expense - Car Insurance Deductible For Accident That Occurred During a Business Trip</code> | <code>As a general rule, you must choose between a mileage deduction or an actual expenses deduction. The idea is that the mileage deduction is supposed to cover all costs of using the car. Exceptions include parking fees and tolls, which can be deducted separately under either method. You explicitly cannot deduct insurance costs if you claim a mileage deduction. Separately, you probably won't be able to deduct the deductible for your car as a casualty loss. You first subtract $100 from the deductible and then divide it by your Adjusted Gross Income (AGI) from your tax return. If your deductible is over 10% of your AGI, you can deduct it. Note that even with a $1500 deductible, you won't be able to deduct anything if you made more than $14,000 for the year. For most people, the insurance deductible just isn't large enough relative to income to be tax deductible. Source</code> |
327
+ | <code>Instruct: Given a web search query, retrieve relevant passages that answer the query<br>Query: Starting a new online business</code> | <code>Most US states have rules that go something like this: You will almost certainly have to pay some registration fees, as noted above. Depending on how you organize, you may or may not need to file a separate tax return for the business. (If you're sole proprietor for tax purposes, then you file on Schedule C on your personal Form 1040.) Whether or not you pay taxes depends on whether you have net income. It's possible that some losses might also be deductible. (Note that you may have to file a return even if you don't have net income - Filing and needing to pay are not the same since your return may indicate no tax due.) In addition, at the state level, you may have to pay additional fees or taxes beyond income tax depending on what you sell and how you sell it. (Sales tax, for example, might come into play as might franchise taxes.) You'll need to check your own state law for that. As always, it could be wise to get professional tax and accounting advice that's tailored to your si...</code> |
328
+ * Loss: <code>zero-neuron.src.embedding.sparse_loss.SparseLoss</code>
329
+
330
+ ### Training Hyperparameters
331
+ #### Non-Default Hyperparameters
332
+
333
+ - `per_device_eval_batch_size`: 16
334
+ - `learning_rate`: 0.0005
335
+ - `num_train_epochs`: 2
336
+ - `lr_scheduler_type`: cosine
337
+ - `warmup_ratio`: 0.01
338
+ - `save_safetensors`: False
339
+ - `bf16`: True
340
+ - `remove_unused_columns`: False
341
+ - `batch_sampler`: no_duplicates
342
+
343
+ #### All Hyperparameters
344
+ <details><summary>Click to expand</summary>
345
+
346
+ - `overwrite_output_dir`: False
347
+ - `do_predict`: False
348
+ - `eval_strategy`: no
349
+ - `prediction_loss_only`: True
350
+ - `per_device_train_batch_size`: 8
351
+ - `per_device_eval_batch_size`: 16
352
+ - `per_gpu_train_batch_size`: None
353
+ - `per_gpu_eval_batch_size`: None
354
+ - `gradient_accumulation_steps`: 1
355
+ - `eval_accumulation_steps`: None
356
+ - `torch_empty_cache_steps`: None
357
+ - `learning_rate`: 0.0005
358
+ - `weight_decay`: 0.0
359
+ - `adam_beta1`: 0.9
360
+ - `adam_beta2`: 0.999
361
+ - `adam_epsilon`: 1e-08
362
+ - `max_grad_norm`: 1.0
363
+ - `num_train_epochs`: 2
364
+ - `max_steps`: -1
365
+ - `lr_scheduler_type`: cosine
366
+ - `lr_scheduler_kwargs`: {}
367
+ - `warmup_ratio`: 0.01
368
+ - `warmup_steps`: 0
369
+ - `log_level`: passive
370
+ - `log_level_replica`: warning
371
+ - `log_on_each_node`: True
372
+ - `logging_nan_inf_filter`: True
373
+ - `save_safetensors`: False
374
+ - `save_on_each_node`: False
375
+ - `save_only_model`: False
376
+ - `restore_callback_states_from_checkpoint`: False
377
+ - `no_cuda`: False
378
+ - `use_cpu`: False
379
+ - `use_mps_device`: False
380
+ - `seed`: 42
381
+ - `data_seed`: None
382
+ - `jit_mode_eval`: False
383
+ - `use_ipex`: False
384
+ - `bf16`: True
385
+ - `fp16`: False
386
+ - `fp16_opt_level`: O1
387
+ - `half_precision_backend`: auto
388
+ - `bf16_full_eval`: False
389
+ - `fp16_full_eval`: False
390
+ - `tf32`: None
391
+ - `local_rank`: 0
392
+ - `ddp_backend`: None
393
+ - `tpu_num_cores`: None
394
+ - `tpu_metrics_debug`: False
395
+ - `debug`: []
396
+ - `dataloader_drop_last`: False
397
+ - `dataloader_num_workers`: 0
398
+ - `dataloader_prefetch_factor`: None
399
+ - `past_index`: -1
400
+ - `disable_tqdm`: False
401
+ - `remove_unused_columns`: False
402
+ - `label_names`: None
403
+ - `load_best_model_at_end`: False
404
+ - `ignore_data_skip`: False
405
+ - `fsdp`: []
406
+ - `fsdp_min_num_params`: 0
407
+ - `fsdp_config`: {'min_num_params': 0, 'xla': False, 'xla_fsdp_v2': False, 'xla_fsdp_grad_ckpt': False}
408
+ - `fsdp_transformer_layer_cls_to_wrap`: None
409
+ - `accelerator_config`: {'split_batches': False, 'dispatch_batches': None, 'even_batches': True, 'use_seedable_sampler': True, 'non_blocking': False, 'gradient_accumulation_kwargs': None}
410
+ - `deepspeed`: None
411
+ - `label_smoothing_factor`: 0.0
412
+ - `optim`: adamw_torch
413
+ - `optim_args`: None
414
+ - `adafactor`: False
415
+ - `group_by_length`: False
416
+ - `length_column_name`: length
417
+ - `ddp_find_unused_parameters`: None
418
+ - `ddp_bucket_cap_mb`: None
419
+ - `ddp_broadcast_buffers`: False
420
+ - `dataloader_pin_memory`: True
421
+ - `dataloader_persistent_workers`: False
422
+ - `skip_memory_metrics`: True
423
+ - `use_legacy_prediction_loop`: False
424
+ - `push_to_hub`: False
425
+ - `resume_from_checkpoint`: None
426
+ - `hub_model_id`: None
427
+ - `hub_strategy`: every_save
428
+ - `hub_private_repo`: None
429
+ - `hub_always_push`: False
430
+ - `hub_revision`: None
431
+ - `gradient_checkpointing`: False
432
+ - `gradient_checkpointing_kwargs`: None
433
+ - `include_inputs_for_metrics`: False
434
+ - `include_for_metrics`: []
435
+ - `eval_do_concat_batches`: True
436
+ - `fp16_backend`: auto
437
+ - `push_to_hub_model_id`: None
438
+ - `push_to_hub_organization`: None
439
+ - `mp_parameters`:
440
+ - `auto_find_batch_size`: False
441
+ - `full_determinism`: False
442
+ - `torchdynamo`: None
443
+ - `ray_scope`: last
444
+ - `ddp_timeout`: 1800
445
+ - `torch_compile`: False
446
+ - `torch_compile_backend`: None
447
+ - `torch_compile_mode`: None
448
+ - `include_tokens_per_second`: False
449
+ - `include_num_input_tokens_seen`: False
450
+ - `neftune_noise_alpha`: None
451
+ - `optim_target_modules`: None
452
+ - `batch_eval_metrics`: False
453
+ - `eval_on_start`: False
454
+ - `use_liger_kernel`: False
455
+ - `liger_kernel_config`: None
456
+ - `eval_use_gather_object`: False
457
+ - `average_tokens_across_devices`: False
458
+ - `prompts`: None
459
+ - `batch_sampler`: no_duplicates
460
+ - `multi_dataset_batch_sampler`: proportional
461
+ - `router_mapping`: {}
462
+ - `learning_rate_mapping`: {}
463
+
464
+ </details>
465
+
466
+ ### Training Logs
467
+ <details><summary>Click to expand</summary>
468
+
469
+ | Epoch | Step | Training Loss |
470
+ |:------:|:----:|:-------------:|
471
+ | 0.0056 | 10 | 1.1694 |
472
+ | 0.0113 | 20 | 1.2809 |
473
+ | 0.0169 | 30 | 1.2538 |
474
+ | 0.0226 | 40 | 1.2237 |
475
+ | 0.0282 | 50 | 1.1809 |
476
+ | 0.0339 | 60 | 1.1602 |
477
+ | 0.0395 | 70 | 1.2008 |
478
+ | 0.0452 | 80 | 1.1064 |
479
+ | 0.0508 | 90 | 1.0857 |
480
+ | 0.0565 | 100 | 1.0553 |
481
+ | 0.0621 | 110 | 1.0513 |
482
+ | 0.0678 | 120 | 0.9236 |
483
+ | 0.0734 | 130 | 0.8998 |
484
+ | 0.0791 | 140 | 0.8509 |
485
+ | 0.0847 | 150 | 0.7769 |
486
+ | 0.0903 | 160 | 0.7268 |
487
+ | 0.0960 | 170 | 0.7287 |
488
+ | 0.1016 | 180 | 0.6437 |
489
+ | 0.1073 | 190 | 0.6653 |
490
+ | 0.1129 | 200 | 0.5888 |
491
+ | 0.1186 | 210 | 0.6097 |
492
+ | 0.1242 | 220 | 0.6939 |
493
+ | 0.1299 | 230 | 0.5969 |
494
+ | 0.1355 | 240 | 0.5333 |
495
+ | 0.1412 | 250 | 0.5143 |
496
+ | 0.1468 | 260 | 0.6152 |
497
+ | 0.1525 | 270 | 0.4779 |
498
+ | 0.1581 | 280 | 0.5182 |
499
+ | 0.1637 | 290 | 0.5724 |
500
+ | 0.1694 | 300 | 0.5073 |
501
+ | 0.1750 | 310 | 0.4924 |
502
+ | 0.1807 | 320 | 0.5219 |
503
+ | 0.1863 | 330 | 0.5621 |
504
+ | 0.1920 | 340 | 0.4535 |
505
+ | 0.1976 | 350 | 0.4818 |
506
+ | 0.2033 | 360 | 0.4773 |
507
+ | 0.2089 | 370 | 0.4948 |
508
+ | 0.2146 | 380 | 0.4277 |
509
+ | 0.2202 | 390 | 0.5043 |
510
+ | 0.2259 | 400 | 0.5746 |
511
+ | 0.2315 | 410 | 0.4762 |
512
+ | 0.2372 | 420 | 0.4432 |
513
+ | 0.2428 | 430 | 0.4771 |
514
+ | 0.2484 | 440 | 0.5298 |
515
+ | 0.2541 | 450 | 0.4352 |
516
+ | 0.2597 | 460 | 0.5714 |
517
+ | 0.2654 | 470 | 0.508 |
518
+ | 0.2710 | 480 | 0.5215 |
519
+ | 0.2767 | 490 | 0.5096 |
520
+ | 0.2823 | 500 | 0.4598 |
521
+ | 0.2880 | 510 | 0.5843 |
522
+ | 0.2936 | 520 | 0.5581 |
523
+ | 0.2993 | 530 | 0.4686 |
524
+ | 0.3049 | 540 | 0.4956 |
525
+ | 0.3106 | 550 | 0.4209 |
526
+ | 0.3162 | 560 | 0.4181 |
527
+ | 0.3219 | 570 | 0.4847 |
528
+ | 0.3275 | 580 | 0.5193 |
529
+ | 0.3331 | 590 | 0.4235 |
530
+ | 0.3388 | 600 | 0.4626 |
531
+ | 0.3444 | 610 | 0.4309 |
532
+ | 0.3501 | 620 | 0.451 |
533
+ | 0.3557 | 630 | 0.4742 |
534
+ | 0.3614 | 640 | 0.4892 |
535
+ | 0.3670 | 650 | 0.4478 |
536
+ | 0.3727 | 660 | 0.4461 |
537
+ | 0.3783 | 670 | 0.5197 |
538
+ | 0.3840 | 680 | 0.4692 |
539
+ | 0.3896 | 690 | 0.4272 |
540
+ | 0.3953 | 700 | 0.4196 |
541
+ | 0.4009 | 710 | 0.4737 |
542
+ | 0.4065 | 720 | 0.4015 |
543
+ | 0.4122 | 730 | 0.4786 |
544
+ | 0.4178 | 740 | 0.3968 |
545
+ | 0.4235 | 750 | 0.4499 |
546
+ | 0.4291 | 760 | 0.478 |
547
+ | 0.4348 | 770 | 0.4003 |
548
+ | 0.4404 | 780 | 0.4679 |
549
+ | 0.4461 | 790 | 0.4129 |
550
+ | 0.4517 | 800 | 0.452 |
551
+ | 0.4574 | 810 | 0.4238 |
552
+ | 0.4630 | 820 | 0.4761 |
553
+ | 0.4687 | 830 | 0.4324 |
554
+ | 0.4743 | 840 | 0.4535 |
555
+ | 0.4800 | 850 | 0.4914 |
556
+ | 0.4856 | 860 | 0.5368 |
557
+ | 0.4912 | 870 | 0.4106 |
558
+ | 0.4969 | 880 | 0.419 |
559
+ | 0.5025 | 890 | 0.3884 |
560
+ | 0.5082 | 900 | 0.4833 |
561
+ | 0.5138 | 910 | 0.4295 |
562
+ | 0.5195 | 920 | 0.3673 |
563
+ | 0.5251 | 930 | 0.4245 |
564
+ | 0.5308 | 940 | 0.4636 |
565
+ | 0.5364 | 950 | 0.3897 |
566
+ | 0.5421 | 960 | 0.4342 |
567
+ | 0.5477 | 970 | 0.442 |
568
+ | 0.5534 | 980 | 0.4443 |
569
+ | 0.5590 | 990 | 0.3737 |
570
+ | 0.5647 | 1000 | 0.441 |
571
+ | 0.5703 | 1010 | 0.4247 |
572
+ | 0.5759 | 1020 | 0.4583 |
573
+ | 0.5816 | 1030 | 0.4077 |
574
+ | 0.5872 | 1040 | 0.5236 |
575
+ | 0.5929 | 1050 | 0.4307 |
576
+ | 0.5985 | 1060 | 0.5054 |
577
+ | 0.6042 | 1070 | 0.4787 |
578
+ | 0.6098 | 1080 | 0.4521 |
579
+ | 0.6155 | 1090 | 0.4011 |
580
+ | 0.6211 | 1100 | 0.3864 |
581
+ | 0.6268 | 1110 | 0.4191 |
582
+ | 0.6324 | 1120 | 0.436 |
583
+ | 0.6381 | 1130 | 0.4469 |
584
+ | 0.6437 | 1140 | 0.4416 |
585
+ | 0.6494 | 1150 | 0.4475 |
586
+ | 0.6550 | 1160 | 0.3857 |
587
+ | 0.6606 | 1170 | 0.3571 |
588
+ | 0.6663 | 1180 | 0.441 |
589
+ | 0.6719 | 1190 | 0.4144 |
590
+ | 0.6776 | 1200 | 0.4108 |
591
+ | 0.6832 | 1210 | 0.4051 |
592
+ | 0.6889 | 1220 | 0.489 |
593
+ | 0.6945 | 1230 | 0.3881 |
594
+ | 0.7002 | 1240 | 0.4971 |
595
+ | 0.7058 | 1250 | 0.415 |
596
+ | 0.7115 | 1260 | 0.4048 |
597
+ | 0.7171 | 1270 | 0.3805 |
598
+ | 0.7228 | 1280 | 0.3869 |
599
+ | 0.7284 | 1290 | 0.3804 |
600
+ | 0.7340 | 1300 | 0.4141 |
601
+ | 0.7397 | 1310 | 0.4223 |
602
+ | 0.7453 | 1320 | 0.3836 |
603
+ | 0.7510 | 1330 | 0.4012 |
604
+ | 0.7566 | 1340 | 0.4725 |
605
+ | 0.7623 | 1350 | 0.3946 |
606
+ | 0.7679 | 1360 | 0.4424 |
607
+ | 0.7736 | 1370 | 0.4256 |
608
+ | 0.7792 | 1380 | 0.4381 |
609
+ | 0.7849 | 1390 | 0.3634 |
610
+ | 0.7905 | 1400 | 0.3568 |
611
+ | 0.7962 | 1410 | 0.4158 |
612
+ | 0.8018 | 1420 | 0.3982 |
613
+ | 0.8075 | 1430 | 0.4734 |
614
+ | 0.8131 | 1440 | 0.3787 |
615
+ | 0.8187 | 1450 | 0.4492 |
616
+ | 0.8244 | 1460 | 0.4504 |
617
+ | 0.8300 | 1470 | 0.4125 |
618
+ | 0.8357 | 1480 | 0.4059 |
619
+ | 0.8413 | 1490 | 0.419 |
620
+ | 0.8470 | 1500 | 0.4269 |
621
+ | 0.8526 | 1510 | 0.5586 |
622
+ | 0.8583 | 1520 | 0.4664 |
623
+ | 0.8639 | 1530 | 0.5185 |
624
+ | 0.8696 | 1540 | 0.422 |
625
+ | 0.8752 | 1550 | 0.5141 |
626
+ | 0.8809 | 1560 | 0.4576 |
627
+ | 0.8865 | 1570 | 0.372 |
628
+ | 0.8922 | 1580 | 0.4194 |
629
+ | 0.8978 | 1590 | 0.4074 |
630
+ | 0.9034 | 1600 | 0.3894 |
631
+ | 0.9091 | 1610 | 0.4172 |
632
+ | 0.9147 | 1620 | 0.4274 |
633
+ | 0.9204 | 1630 | 0.4013 |
634
+ | 0.9260 | 1640 | 0.4072 |
635
+ | 0.9317 | 1650 | 0.3616 |
636
+ | 0.9373 | 1660 | 0.3485 |
637
+ | 0.9430 | 1670 | 0.4478 |
638
+ | 0.9486 | 1680 | 0.4543 |
639
+ | 0.9543 | 1690 | 0.4229 |
640
+ | 0.9599 | 1700 | 0.4186 |
641
+ | 0.9656 | 1710 | 0.378 |
642
+ | 0.9712 | 1720 | 0.3753 |
643
+ | 0.9768 | 1730 | 0.4575 |
644
+ | 0.9825 | 1740 | 0.4291 |
645
+ | 0.9881 | 1750 | 0.4288 |
646
+ | 0.9938 | 1760 | 0.3678 |
647
+ | 0.9994 | 1770 | 0.5298 |
648
+ | 1.0051 | 1780 | 0.3926 |
649
+ | 1.0107 | 1790 | 0.3799 |
650
+ | 1.0164 | 1800 | 0.4288 |
651
+ | 1.0220 | 1810 | 0.4323 |
652
+ | 1.0277 | 1820 | 0.4371 |
653
+ | 1.0333 | 1830 | 0.4652 |
654
+ | 1.0390 | 1840 | 0.3565 |
655
+ | 1.0446 | 1850 | 0.4567 |
656
+ | 1.0503 | 1860 | 0.3947 |
657
+ | 1.0559 | 1870 | 0.3868 |
658
+ | 1.0615 | 1880 | 0.4143 |
659
+ | 1.0672 | 1890 | 0.482 |
660
+ | 1.0728 | 1900 | 0.3763 |
661
+ | 1.0785 | 1910 | 0.3795 |
662
+ | 1.0841 | 1920 | 0.4413 |
663
+ | 1.0898 | 1930 | 0.4761 |
664
+ | 1.0954 | 1940 | 0.3907 |
665
+ | 1.1011 | 1950 | 0.4066 |
666
+ | 1.1067 | 1960 | 0.3905 |
667
+ | 1.1124 | 1970 | 0.3944 |
668
+ | 1.1180 | 1980 | 0.4022 |
669
+ | 1.1237 | 1990 | 0.398 |
670
+ | 1.1293 | 2000 | 0.3473 |
671
+ | 1.1350 | 2010 | 0.4357 |
672
+ | 1.1406 | 2020 | 0.3823 |
673
+ | 1.1462 | 2030 | 0.3628 |
674
+ | 1.1519 | 2040 | 0.403 |
675
+ | 1.1575 | 2050 | 0.3965 |
676
+ | 1.1632 | 2060 | 0.3837 |
677
+ | 1.1688 | 2070 | 0.5012 |
678
+ | 1.1745 | 2080 | 0.3959 |
679
+ | 1.1801 | 2090 | 0.3661 |
680
+ | 1.1858 | 2100 | 0.4603 |
681
+ | 1.1914 | 2110 | 0.4607 |
682
+ | 1.1971 | 2120 | 0.4241 |
683
+ | 1.2027 | 2130 | 0.5183 |
684
+ | 1.2084 | 2140 | 0.3533 |
685
+ | 1.2140 | 2150 | 0.3877 |
686
+ | 1.2196 | 2160 | 0.4298 |
687
+ | 1.2253 | 2170 | 0.4228 |
688
+ | 1.2309 | 2180 | 0.4131 |
689
+ | 1.2366 | 2190 | 0.4034 |
690
+ | 1.2422 | 2200 | 0.3834 |
691
+ | 1.2479 | 2210 | 0.4183 |
692
+ | 1.2535 | 2220 | 0.5475 |
693
+ | 1.2592 | 2230 | 0.4755 |
694
+ | 1.2648 | 2240 | 0.4478 |
695
+ | 1.2705 | 2250 | 0.3763 |
696
+ | 1.2761 | 2260 | 0.4493 |
697
+ | 1.2818 | 2270 | 0.4001 |
698
+ | 1.2874 | 2280 | 0.3765 |
699
+ | 1.2931 | 2290 | 0.3379 |
700
+ | 1.2987 | 2300 | 0.337 |
701
+ | 1.3043 | 2310 | 0.4143 |
702
+ | 1.3100 | 2320 | 0.4794 |
703
+ | 1.3156 | 2330 | 0.4004 |
704
+ | 1.3213 | 2340 | 0.3674 |
705
+ | 1.3269 | 2350 | 0.3963 |
706
+ | 1.3326 | 2360 | 0.3896 |
707
+ | 1.3382 | 2370 | 0.5062 |
708
+ | 1.3439 | 2380 | 0.4114 |
709
+ | 1.3495 | 2390 | 0.3955 |
710
+ | 1.3552 | 2400 | 0.4682 |
711
+ | 1.3608 | 2410 | 0.3551 |
712
+ | 1.3665 | 2420 | 0.3536 |
713
+ | 1.3721 | 2430 | 0.3784 |
714
+ | 1.3778 | 2440 | 0.3456 |
715
+ | 1.3834 | 2450 | 0.4273 |
716
+ | 1.3890 | 2460 | 0.4005 |
717
+ | 1.3947 | 2470 | 0.3957 |
718
+ | 1.4003 | 2480 | 0.3371 |
719
+ | 1.4060 | 2490 | 0.3451 |
720
+ | 1.4116 | 2500 | 0.4735 |
721
+ | 1.4173 | 2510 | 0.4013 |
722
+ | 1.4229 | 2520 | 0.3751 |
723
+ | 1.4286 | 2530 | 0.365 |
724
+ | 1.4342 | 2540 | 0.3548 |
725
+ | 1.4399 | 2550 | 0.4227 |
726
+ | 1.4455 | 2560 | 0.3626 |
727
+ | 1.4512 | 2570 | 0.404 |
728
+ | 1.4568 | 2580 | 0.4055 |
729
+ | 1.4625 | 2590 | 0.4513 |
730
+ | 1.4681 | 2600 | 0.4147 |
731
+ | 1.4737 | 2610 | 0.3623 |
732
+ | 1.4794 | 2620 | 0.404 |
733
+ | 1.4850 | 2630 | 0.4 |
734
+ | 1.4907 | 2640 | 0.3854 |
735
+ | 1.4963 | 2650 | 0.4082 |
736
+ | 1.5020 | 2660 | 0.3502 |
737
+ | 1.5076 | 2670 | 0.4022 |
738
+ | 1.5133 | 2680 | 0.4479 |
739
+ | 1.5189 | 2690 | 0.3456 |
740
+ | 1.5246 | 2700 | 0.3992 |
741
+ | 1.5302 | 2710 | 0.4143 |
742
+ | 1.5359 | 2720 | 0.3925 |
743
+ | 1.5415 | 2730 | 0.366 |
744
+ | 1.5471 | 2740 | 0.4254 |
745
+ | 1.5528 | 2750 | 0.4337 |
746
+ | 1.5584 | 2760 | 0.471 |
747
+ | 1.5641 | 2770 | 0.4201 |
748
+ | 1.5697 | 2780 | 0.4357 |
749
+ | 1.5754 | 2790 | 0.4289 |
750
+ | 1.5810 | 2800 | 0.4287 |
751
+ | 1.5867 | 2810 | 0.4349 |
752
+ | 1.5923 | 2820 | 0.4551 |
753
+ | 1.5980 | 2830 | 0.3562 |
754
+ | 1.6036 | 2840 | 0.4925 |
755
+ | 1.6093 | 2850 | 0.4104 |
756
+ | 1.6149 | 2860 | 0.4691 |
757
+ | 1.6206 | 2870 | 0.383 |
758
+ | 1.6262 | 2880 | 0.3612 |
759
+ | 1.6318 | 2890 | 0.4584 |
760
+ | 1.6375 | 2900 | 0.3828 |
761
+ | 1.6431 | 2910 | 0.3784 |
762
+ | 1.6488 | 2920 | 0.4148 |
763
+ | 1.6544 | 2930 | 0.4535 |
764
+ | 1.6601 | 2940 | 0.3523 |
765
+ | 1.6657 | 2950 | 0.3501 |
766
+ | 1.6714 | 2960 | 0.3703 |
767
+ | 1.6770 | 2970 | 0.388 |
768
+ | 1.6827 | 2980 | 0.3846 |
769
+ | 1.6883 | 2990 | 0.4212 |
770
+ | 1.6940 | 3000 | 0.4192 |
771
+ | 1.6996 | 3010 | 0.4265 |
772
+ | 1.7053 | 3020 | 0.4385 |
773
+ | 1.7109 | 3030 | 0.4197 |
774
+ | 1.7165 | 3040 | 0.3488 |
775
+ | 1.7222 | 3050 | 0.3666 |
776
+ | 1.7278 | 3060 | 0.3909 |
777
+ | 1.7335 | 3070 | 0.5085 |
778
+ | 1.7391 | 3080 | 0.3495 |
779
+ | 1.7448 | 3090 | 0.4198 |
780
+ | 1.7504 | 3100 | 0.3647 |
781
+ | 1.7561 | 3110 | 0.3873 |
782
+ | 1.7617 | 3120 | 0.4038 |
783
+ | 1.7674 | 3130 | 0.4471 |
784
+ | 1.7730 | 3140 | 0.4078 |
785
+ | 1.7787 | 3150 | 0.3823 |
786
+ | 1.7843 | 3160 | 0.4852 |
787
+ | 1.7899 | 3170 | 0.3891 |
788
+ | 1.7956 | 3180 | 0.4334 |
789
+ | 1.8012 | 3190 | 0.3836 |
790
+ | 1.8069 | 3200 | 0.4 |
791
+ | 1.8125 | 3210 | 0.4126 |
792
+ | 1.8182 | 3220 | 0.3767 |
793
+ | 1.8238 | 3230 | 0.4085 |
794
+ | 1.8295 | 3240 | 0.3919 |
795
+ | 1.8351 | 3250 | 0.358 |
796
+ | 1.8408 | 3260 | 0.3709 |
797
+ | 1.8464 | 3270 | 0.4131 |
798
+ | 1.8521 | 3280 | 0.4082 |
799
+ | 1.8577 | 3290 | 0.4547 |
800
+ | 1.8634 | 3300 | 0.4317 |
801
+ | 1.8690 | 3310 | 0.3981 |
802
+ | 1.8746 | 3320 | 0.4585 |
803
+ | 1.8803 | 3330 | 0.3698 |
804
+ | 1.8859 | 3340 | 0.3662 |
805
+ | 1.8916 | 3350 | 0.3955 |
806
+ | 1.8972 | 3360 | 0.4387 |
807
+ | 1.9029 | 3370 | 0.5001 |
808
+ | 1.9085 | 3380 | 0.3708 |
809
+ | 1.9142 | 3390 | 0.4448 |
810
+ | 1.9198 | 3400 | 0.3632 |
811
+ | 1.9255 | 3410 | 0.4589 |
812
+ | 1.9311 | 3420 | 0.4085 |
813
+ | 1.9368 | 3430 | 0.3993 |
814
+ | 1.9424 | 3440 | 0.4598 |
815
+ | 1.9481 | 3450 | 0.4019 |
816
+ | 1.9537 | 3460 | 0.4179 |
817
+ | 1.9593 | 3470 | 0.3804 |
818
+ | 1.9650 | 3480 | 0.4229 |
819
+ | 1.9706 | 3490 | 0.3933 |
820
+ | 1.9763 | 3500 | 0.4217 |
821
+ | 1.9819 | 3510 | 0.4182 |
822
+ | 1.9876 | 3520 | 0.5265 |
823
+ | 1.9932 | 3530 | 0.403 |
824
+ | 1.9989 | 3540 | 0.3758 |
825
+
826
+ </details>
827
+
828
+ ### Framework Versions
829
+ - Python: 3.10.16
830
+ - Sentence Transformers: 5.1.1
831
+ - Transformers: 4.55.4
832
+ - PyTorch: 2.6.0+cu124
833
+ - Accelerate: 1.8.0.dev0
834
+ - Datasets: 3.2.0
835
+ - Tokenizers: 0.21.4
836
+
837
+ ## Citation
838
+
839
+ ### BibTeX
840
+
841
+ #### Sentence Transformers
842
+ ```bibtex
843
+ @inproceedings{reimers-2019-sentence-bert,
844
+ title = "Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks",
845
+ author = "Reimers, Nils and Gurevych, Iryna",
846
+ booktitle = "Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing",
847
+ month = "11",
848
+ year = "2019",
849
+ publisher = "Association for Computational Linguistics",
850
+ url = "https://arxiv.org/abs/1908.10084",
851
+ }
852
+ ```
853
+
854
+ #### MultipleNegativesRankingLoss
855
+ ```bibtex
856
+ @misc{henderson2017efficient,
857
+ title={Efficient Natural Language Response Suggestion for Smart Reply},
858
+ author={Matthew Henderson and Rami Al-Rfou and Brian Strope and Yun-hsuan Sung and Laszlo Lukacs and Ruiqi Guo and Sanjiv Kumar and Balint Miklos and Ray Kurzweil},
859
+ year={2017},
860
+ eprint={1705.00652},
861
+ archivePrefix={arXiv},
862
+ primaryClass={cs.CL}
863
+ }
864
+ ```
865
+
866
+ <!--
867
+ ## Glossary
868
+
869
+ *Clearly define terms in order to be accessible across audiences.*
870
+ -->
871
+
872
+ <!--
873
+ ## Model Card Authors
874
+
875
+ *Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction.*
876
+ -->
877
+
878
+ <!--
879
+ ## Model Card Contact
880
+
881
+ *Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors.*
882
+ -->
config.json ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "MistralModel"
4
+ ],
5
+ "attention_dropout": 0.0,
6
+ "bos_token_id": 1,
7
+ "eos_token_id": 2,
8
+ "head_dim": null,
9
+ "hidden_act": "silu",
10
+ "hidden_size": 4096,
11
+ "initializer_range": 0.02,
12
+ "intermediate_size": 14336,
13
+ "max_position_embeddings": 32768,
14
+ "model_type": "mistral",
15
+ "num_attention_heads": 32,
16
+ "num_hidden_layers": 32,
17
+ "num_key_value_heads": 8,
18
+ "pad_token_id": 2,
19
+ "rms_norm_eps": 1e-05,
20
+ "rope_theta": 10000.0,
21
+ "sliding_window": 4096,
22
+ "tie_word_embeddings": false,
23
+ "torch_dtype": "bfloat16",
24
+ "transformers_version": "4.55.4",
25
+ "use_cache": false,
26
+ "vocab_size": 32000
27
+ }
config_sentence_transformers.json ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model_type": "SentenceTransformer",
3
+ "__version__": {
4
+ "sentence_transformers": "5.1.1",
5
+ "transformers": "4.55.4",
6
+ "pytorch": "2.6.0+cu124"
7
+ },
8
+ "prompts": {
9
+ "query": "",
10
+ "document": ""
11
+ },
12
+ "default_prompt_name": null,
13
+ "similarity_fn_name": "cosine"
14
+ }
model-00001-of-00003.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b854e9aacc16eaa0006a0f7cc62b0c3be2829841c470830f69b5c117f08230c7
3
+ size 4943161760
model-00002-of-00003.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b8bb4d21e13ec794602e019ddfb3fd6513d6f977e27de30ee109fb554f3ac4be
3
+ size 4999818704
model-00003-of-00003.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a222fc5797efc6e22d094ccd0bfd3475598df41cb69a435fcbafd0a61e9c7493
3
+ size 4278371712
model.safetensors.index.json ADDED
@@ -0,0 +1,298 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "metadata": {
3
+ "total_parameters": 7110660096,
4
+ "total_size": 14221320192
5
+ },
6
+ "weight_map": {
7
+ "embed_tokens.weight": "model-00001-of-00003.safetensors",
8
+ "layers.0.input_layernorm.weight": "model-00001-of-00003.safetensors",
9
+ "layers.0.mlp.down_proj.weight": "model-00001-of-00003.safetensors",
10
+ "layers.0.mlp.gate_proj.weight": "model-00001-of-00003.safetensors",
11
+ "layers.0.mlp.up_proj.weight": "model-00001-of-00003.safetensors",
12
+ "layers.0.post_attention_layernorm.weight": "model-00001-of-00003.safetensors",
13
+ "layers.0.self_attn.k_proj.weight": "model-00001-of-00003.safetensors",
14
+ "layers.0.self_attn.o_proj.weight": "model-00001-of-00003.safetensors",
15
+ "layers.0.self_attn.q_proj.weight": "model-00001-of-00003.safetensors",
16
+ "layers.0.self_attn.v_proj.weight": "model-00001-of-00003.safetensors",
17
+ "layers.1.input_layernorm.weight": "model-00001-of-00003.safetensors",
18
+ "layers.1.mlp.down_proj.weight": "model-00001-of-00003.safetensors",
19
+ "layers.1.mlp.gate_proj.weight": "model-00001-of-00003.safetensors",
20
+ "layers.1.mlp.up_proj.weight": "model-00001-of-00003.safetensors",
21
+ "layers.1.post_attention_layernorm.weight": "model-00001-of-00003.safetensors",
22
+ "layers.1.self_attn.k_proj.weight": "model-00001-of-00003.safetensors",
23
+ "layers.1.self_attn.o_proj.weight": "model-00001-of-00003.safetensors",
24
+ "layers.1.self_attn.q_proj.weight": "model-00001-of-00003.safetensors",
25
+ "layers.1.self_attn.v_proj.weight": "model-00001-of-00003.safetensors",
26
+ "layers.10.input_layernorm.weight": "model-00002-of-00003.safetensors",
27
+ "layers.10.mlp.down_proj.weight": "model-00002-of-00003.safetensors",
28
+ "layers.10.mlp.gate_proj.weight": "model-00001-of-00003.safetensors",
29
+ "layers.10.mlp.up_proj.weight": "model-00001-of-00003.safetensors",
30
+ "layers.10.post_attention_layernorm.weight": "model-00002-of-00003.safetensors",
31
+ "layers.10.self_attn.k_proj.weight": "model-00001-of-00003.safetensors",
32
+ "layers.10.self_attn.o_proj.weight": "model-00001-of-00003.safetensors",
33
+ "layers.10.self_attn.q_proj.weight": "model-00001-of-00003.safetensors",
34
+ "layers.10.self_attn.v_proj.weight": "model-00001-of-00003.safetensors",
35
+ "layers.11.input_layernorm.weight": "model-00002-of-00003.safetensors",
36
+ "layers.11.mlp.down_proj.weight": "model-00002-of-00003.safetensors",
37
+ "layers.11.mlp.gate_proj.weight": "model-00002-of-00003.safetensors",
38
+ "layers.11.mlp.up_proj.weight": "model-00002-of-00003.safetensors",
39
+ "layers.11.post_attention_layernorm.weight": "model-00002-of-00003.safetensors",
40
+ "layers.11.self_attn.k_proj.weight": "model-00002-of-00003.safetensors",
41
+ "layers.11.self_attn.o_proj.weight": "model-00002-of-00003.safetensors",
42
+ "layers.11.self_attn.q_proj.weight": "model-00002-of-00003.safetensors",
43
+ "layers.11.self_attn.v_proj.weight": "model-00002-of-00003.safetensors",
44
+ "layers.12.input_layernorm.weight": "model-00002-of-00003.safetensors",
45
+ "layers.12.mlp.down_proj.weight": "model-00002-of-00003.safetensors",
46
+ "layers.12.mlp.gate_proj.weight": "model-00002-of-00003.safetensors",
47
+ "layers.12.mlp.up_proj.weight": "model-00002-of-00003.safetensors",
48
+ "layers.12.post_attention_layernorm.weight": "model-00002-of-00003.safetensors",
49
+ "layers.12.self_attn.k_proj.weight": "model-00002-of-00003.safetensors",
50
+ "layers.12.self_attn.o_proj.weight": "model-00002-of-00003.safetensors",
51
+ "layers.12.self_attn.q_proj.weight": "model-00002-of-00003.safetensors",
52
+ "layers.12.self_attn.v_proj.weight": "model-00002-of-00003.safetensors",
53
+ "layers.13.input_layernorm.weight": "model-00002-of-00003.safetensors",
54
+ "layers.13.mlp.down_proj.weight": "model-00002-of-00003.safetensors",
55
+ "layers.13.mlp.gate_proj.weight": "model-00002-of-00003.safetensors",
56
+ "layers.13.mlp.up_proj.weight": "model-00002-of-00003.safetensors",
57
+ "layers.13.post_attention_layernorm.weight": "model-00002-of-00003.safetensors",
58
+ "layers.13.self_attn.k_proj.weight": "model-00002-of-00003.safetensors",
59
+ "layers.13.self_attn.o_proj.weight": "model-00002-of-00003.safetensors",
60
+ "layers.13.self_attn.q_proj.weight": "model-00002-of-00003.safetensors",
61
+ "layers.13.self_attn.v_proj.weight": "model-00002-of-00003.safetensors",
62
+ "layers.14.input_layernorm.weight": "model-00002-of-00003.safetensors",
63
+ "layers.14.mlp.down_proj.weight": "model-00002-of-00003.safetensors",
64
+ "layers.14.mlp.gate_proj.weight": "model-00002-of-00003.safetensors",
65
+ "layers.14.mlp.up_proj.weight": "model-00002-of-00003.safetensors",
66
+ "layers.14.post_attention_layernorm.weight": "model-00002-of-00003.safetensors",
67
+ "layers.14.self_attn.k_proj.weight": "model-00002-of-00003.safetensors",
68
+ "layers.14.self_attn.o_proj.weight": "model-00002-of-00003.safetensors",
69
+ "layers.14.self_attn.q_proj.weight": "model-00002-of-00003.safetensors",
70
+ "layers.14.self_attn.v_proj.weight": "model-00002-of-00003.safetensors",
71
+ "layers.15.input_layernorm.weight": "model-00002-of-00003.safetensors",
72
+ "layers.15.mlp.down_proj.weight": "model-00002-of-00003.safetensors",
73
+ "layers.15.mlp.gate_proj.weight": "model-00002-of-00003.safetensors",
74
+ "layers.15.mlp.up_proj.weight": "model-00002-of-00003.safetensors",
75
+ "layers.15.post_attention_layernorm.weight": "model-00002-of-00003.safetensors",
76
+ "layers.15.self_attn.k_proj.weight": "model-00002-of-00003.safetensors",
77
+ "layers.15.self_attn.o_proj.weight": "model-00002-of-00003.safetensors",
78
+ "layers.15.self_attn.q_proj.weight": "model-00002-of-00003.safetensors",
79
+ "layers.15.self_attn.v_proj.weight": "model-00002-of-00003.safetensors",
80
+ "layers.16.input_layernorm.weight": "model-00002-of-00003.safetensors",
81
+ "layers.16.mlp.down_proj.weight": "model-00002-of-00003.safetensors",
82
+ "layers.16.mlp.gate_proj.weight": "model-00002-of-00003.safetensors",
83
+ "layers.16.mlp.up_proj.weight": "model-00002-of-00003.safetensors",
84
+ "layers.16.post_attention_layernorm.weight": "model-00002-of-00003.safetensors",
85
+ "layers.16.self_attn.k_proj.weight": "model-00002-of-00003.safetensors",
86
+ "layers.16.self_attn.o_proj.weight": "model-00002-of-00003.safetensors",
87
+ "layers.16.self_attn.q_proj.weight": "model-00002-of-00003.safetensors",
88
+ "layers.16.self_attn.v_proj.weight": "model-00002-of-00003.safetensors",
89
+ "layers.17.input_layernorm.weight": "model-00002-of-00003.safetensors",
90
+ "layers.17.mlp.down_proj.weight": "model-00002-of-00003.safetensors",
91
+ "layers.17.mlp.gate_proj.weight": "model-00002-of-00003.safetensors",
92
+ "layers.17.mlp.up_proj.weight": "model-00002-of-00003.safetensors",
93
+ "layers.17.post_attention_layernorm.weight": "model-00002-of-00003.safetensors",
94
+ "layers.17.self_attn.k_proj.weight": "model-00002-of-00003.safetensors",
95
+ "layers.17.self_attn.o_proj.weight": "model-00002-of-00003.safetensors",
96
+ "layers.17.self_attn.q_proj.weight": "model-00002-of-00003.safetensors",
97
+ "layers.17.self_attn.v_proj.weight": "model-00002-of-00003.safetensors",
98
+ "layers.18.input_layernorm.weight": "model-00002-of-00003.safetensors",
99
+ "layers.18.mlp.down_proj.weight": "model-00002-of-00003.safetensors",
100
+ "layers.18.mlp.gate_proj.weight": "model-00002-of-00003.safetensors",
101
+ "layers.18.mlp.up_proj.weight": "model-00002-of-00003.safetensors",
102
+ "layers.18.post_attention_layernorm.weight": "model-00002-of-00003.safetensors",
103
+ "layers.18.self_attn.k_proj.weight": "model-00002-of-00003.safetensors",
104
+ "layers.18.self_attn.o_proj.weight": "model-00002-of-00003.safetensors",
105
+ "layers.18.self_attn.q_proj.weight": "model-00002-of-00003.safetensors",
106
+ "layers.18.self_attn.v_proj.weight": "model-00002-of-00003.safetensors",
107
+ "layers.19.input_layernorm.weight": "model-00002-of-00003.safetensors",
108
+ "layers.19.mlp.down_proj.weight": "model-00002-of-00003.safetensors",
109
+ "layers.19.mlp.gate_proj.weight": "model-00002-of-00003.safetensors",
110
+ "layers.19.mlp.up_proj.weight": "model-00002-of-00003.safetensors",
111
+ "layers.19.post_attention_layernorm.weight": "model-00002-of-00003.safetensors",
112
+ "layers.19.self_attn.k_proj.weight": "model-00002-of-00003.safetensors",
113
+ "layers.19.self_attn.o_proj.weight": "model-00002-of-00003.safetensors",
114
+ "layers.19.self_attn.q_proj.weight": "model-00002-of-00003.safetensors",
115
+ "layers.19.self_attn.v_proj.weight": "model-00002-of-00003.safetensors",
116
+ "layers.2.input_layernorm.weight": "model-00001-of-00003.safetensors",
117
+ "layers.2.mlp.down_proj.weight": "model-00001-of-00003.safetensors",
118
+ "layers.2.mlp.gate_proj.weight": "model-00001-of-00003.safetensors",
119
+ "layers.2.mlp.up_proj.weight": "model-00001-of-00003.safetensors",
120
+ "layers.2.post_attention_layernorm.weight": "model-00001-of-00003.safetensors",
121
+ "layers.2.self_attn.k_proj.weight": "model-00001-of-00003.safetensors",
122
+ "layers.2.self_attn.o_proj.weight": "model-00001-of-00003.safetensors",
123
+ "layers.2.self_attn.q_proj.weight": "model-00001-of-00003.safetensors",
124
+ "layers.2.self_attn.v_proj.weight": "model-00001-of-00003.safetensors",
125
+ "layers.20.input_layernorm.weight": "model-00002-of-00003.safetensors",
126
+ "layers.20.mlp.down_proj.weight": "model-00002-of-00003.safetensors",
127
+ "layers.20.mlp.gate_proj.weight": "model-00002-of-00003.safetensors",
128
+ "layers.20.mlp.up_proj.weight": "model-00002-of-00003.safetensors",
129
+ "layers.20.post_attention_layernorm.weight": "model-00002-of-00003.safetensors",
130
+ "layers.20.self_attn.k_proj.weight": "model-00002-of-00003.safetensors",
131
+ "layers.20.self_attn.o_proj.weight": "model-00002-of-00003.safetensors",
132
+ "layers.20.self_attn.q_proj.weight": "model-00002-of-00003.safetensors",
133
+ "layers.20.self_attn.v_proj.weight": "model-00002-of-00003.safetensors",
134
+ "layers.21.input_layernorm.weight": "model-00002-of-00003.safetensors",
135
+ "layers.21.mlp.down_proj.weight": "model-00002-of-00003.safetensors",
136
+ "layers.21.mlp.gate_proj.weight": "model-00002-of-00003.safetensors",
137
+ "layers.21.mlp.up_proj.weight": "model-00002-of-00003.safetensors",
138
+ "layers.21.post_attention_layernorm.weight": "model-00002-of-00003.safetensors",
139
+ "layers.21.self_attn.k_proj.weight": "model-00002-of-00003.safetensors",
140
+ "layers.21.self_attn.o_proj.weight": "model-00002-of-00003.safetensors",
141
+ "layers.21.self_attn.q_proj.weight": "model-00002-of-00003.safetensors",
142
+ "layers.21.self_attn.v_proj.weight": "model-00002-of-00003.safetensors",
143
+ "layers.22.input_layernorm.weight": "model-00003-of-00003.safetensors",
144
+ "layers.22.mlp.down_proj.weight": "model-00003-of-00003.safetensors",
145
+ "layers.22.mlp.gate_proj.weight": "model-00003-of-00003.safetensors",
146
+ "layers.22.mlp.up_proj.weight": "model-00003-of-00003.safetensors",
147
+ "layers.22.post_attention_layernorm.weight": "model-00003-of-00003.safetensors",
148
+ "layers.22.self_attn.k_proj.weight": "model-00002-of-00003.safetensors",
149
+ "layers.22.self_attn.o_proj.weight": "model-00002-of-00003.safetensors",
150
+ "layers.22.self_attn.q_proj.weight": "model-00002-of-00003.safetensors",
151
+ "layers.22.self_attn.v_proj.weight": "model-00002-of-00003.safetensors",
152
+ "layers.23.input_layernorm.weight": "model-00003-of-00003.safetensors",
153
+ "layers.23.mlp.down_proj.weight": "model-00003-of-00003.safetensors",
154
+ "layers.23.mlp.gate_proj.weight": "model-00003-of-00003.safetensors",
155
+ "layers.23.mlp.up_proj.weight": "model-00003-of-00003.safetensors",
156
+ "layers.23.post_attention_layernorm.weight": "model-00003-of-00003.safetensors",
157
+ "layers.23.self_attn.k_proj.weight": "model-00003-of-00003.safetensors",
158
+ "layers.23.self_attn.o_proj.weight": "model-00003-of-00003.safetensors",
159
+ "layers.23.self_attn.q_proj.weight": "model-00003-of-00003.safetensors",
160
+ "layers.23.self_attn.v_proj.weight": "model-00003-of-00003.safetensors",
161
+ "layers.24.input_layernorm.weight": "model-00003-of-00003.safetensors",
162
+ "layers.24.mlp.down_proj.weight": "model-00003-of-00003.safetensors",
163
+ "layers.24.mlp.gate_proj.weight": "model-00003-of-00003.safetensors",
164
+ "layers.24.mlp.up_proj.weight": "model-00003-of-00003.safetensors",
165
+ "layers.24.post_attention_layernorm.weight": "model-00003-of-00003.safetensors",
166
+ "layers.24.self_attn.k_proj.weight": "model-00003-of-00003.safetensors",
167
+ "layers.24.self_attn.o_proj.weight": "model-00003-of-00003.safetensors",
168
+ "layers.24.self_attn.q_proj.weight": "model-00003-of-00003.safetensors",
169
+ "layers.24.self_attn.v_proj.weight": "model-00003-of-00003.safetensors",
170
+ "layers.25.input_layernorm.weight": "model-00003-of-00003.safetensors",
171
+ "layers.25.mlp.down_proj.weight": "model-00003-of-00003.safetensors",
172
+ "layers.25.mlp.gate_proj.weight": "model-00003-of-00003.safetensors",
173
+ "layers.25.mlp.up_proj.weight": "model-00003-of-00003.safetensors",
174
+ "layers.25.post_attention_layernorm.weight": "model-00003-of-00003.safetensors",
175
+ "layers.25.self_attn.k_proj.weight": "model-00003-of-00003.safetensors",
176
+ "layers.25.self_attn.o_proj.weight": "model-00003-of-00003.safetensors",
177
+ "layers.25.self_attn.q_proj.weight": "model-00003-of-00003.safetensors",
178
+ "layers.25.self_attn.v_proj.weight": "model-00003-of-00003.safetensors",
179
+ "layers.26.input_layernorm.weight": "model-00003-of-00003.safetensors",
180
+ "layers.26.mlp.down_proj.weight": "model-00003-of-00003.safetensors",
181
+ "layers.26.mlp.gate_proj.weight": "model-00003-of-00003.safetensors",
182
+ "layers.26.mlp.up_proj.weight": "model-00003-of-00003.safetensors",
183
+ "layers.26.post_attention_layernorm.weight": "model-00003-of-00003.safetensors",
184
+ "layers.26.self_attn.k_proj.weight": "model-00003-of-00003.safetensors",
185
+ "layers.26.self_attn.o_proj.weight": "model-00003-of-00003.safetensors",
186
+ "layers.26.self_attn.q_proj.weight": "model-00003-of-00003.safetensors",
187
+ "layers.26.self_attn.v_proj.weight": "model-00003-of-00003.safetensors",
188
+ "layers.27.input_layernorm.weight": "model-00003-of-00003.safetensors",
189
+ "layers.27.mlp.down_proj.weight": "model-00003-of-00003.safetensors",
190
+ "layers.27.mlp.gate_proj.weight": "model-00003-of-00003.safetensors",
191
+ "layers.27.mlp.up_proj.weight": "model-00003-of-00003.safetensors",
192
+ "layers.27.post_attention_layernorm.weight": "model-00003-of-00003.safetensors",
193
+ "layers.27.self_attn.k_proj.weight": "model-00003-of-00003.safetensors",
194
+ "layers.27.self_attn.o_proj.weight": "model-00003-of-00003.safetensors",
195
+ "layers.27.self_attn.q_proj.weight": "model-00003-of-00003.safetensors",
196
+ "layers.27.self_attn.v_proj.weight": "model-00003-of-00003.safetensors",
197
+ "layers.28.input_layernorm.weight": "model-00003-of-00003.safetensors",
198
+ "layers.28.mlp.down_proj.weight": "model-00003-of-00003.safetensors",
199
+ "layers.28.mlp.gate_proj.weight": "model-00003-of-00003.safetensors",
200
+ "layers.28.mlp.up_proj.weight": "model-00003-of-00003.safetensors",
201
+ "layers.28.post_attention_layernorm.weight": "model-00003-of-00003.safetensors",
202
+ "layers.28.self_attn.k_proj.weight": "model-00003-of-00003.safetensors",
203
+ "layers.28.self_attn.o_proj.weight": "model-00003-of-00003.safetensors",
204
+ "layers.28.self_attn.q_proj.weight": "model-00003-of-00003.safetensors",
205
+ "layers.28.self_attn.v_proj.weight": "model-00003-of-00003.safetensors",
206
+ "layers.29.input_layernorm.weight": "model-00003-of-00003.safetensors",
207
+ "layers.29.mlp.down_proj.weight": "model-00003-of-00003.safetensors",
208
+ "layers.29.mlp.gate_proj.weight": "model-00003-of-00003.safetensors",
209
+ "layers.29.mlp.up_proj.weight": "model-00003-of-00003.safetensors",
210
+ "layers.29.post_attention_layernorm.weight": "model-00003-of-00003.safetensors",
211
+ "layers.29.self_attn.k_proj.weight": "model-00003-of-00003.safetensors",
212
+ "layers.29.self_attn.o_proj.weight": "model-00003-of-00003.safetensors",
213
+ "layers.29.self_attn.q_proj.weight": "model-00003-of-00003.safetensors",
214
+ "layers.29.self_attn.v_proj.weight": "model-00003-of-00003.safetensors",
215
+ "layers.3.input_layernorm.weight": "model-00001-of-00003.safetensors",
216
+ "layers.3.mlp.down_proj.weight": "model-00001-of-00003.safetensors",
217
+ "layers.3.mlp.gate_proj.weight": "model-00001-of-00003.safetensors",
218
+ "layers.3.mlp.up_proj.weight": "model-00001-of-00003.safetensors",
219
+ "layers.3.post_attention_layernorm.weight": "model-00001-of-00003.safetensors",
220
+ "layers.3.self_attn.k_proj.weight": "model-00001-of-00003.safetensors",
221
+ "layers.3.self_attn.o_proj.weight": "model-00001-of-00003.safetensors",
222
+ "layers.3.self_attn.q_proj.weight": "model-00001-of-00003.safetensors",
223
+ "layers.3.self_attn.v_proj.weight": "model-00001-of-00003.safetensors",
224
+ "layers.30.input_layernorm.weight": "model-00003-of-00003.safetensors",
225
+ "layers.30.mlp.down_proj.weight": "model-00003-of-00003.safetensors",
226
+ "layers.30.mlp.gate_proj.weight": "model-00003-of-00003.safetensors",
227
+ "layers.30.mlp.up_proj.weight": "model-00003-of-00003.safetensors",
228
+ "layers.30.post_attention_layernorm.weight": "model-00003-of-00003.safetensors",
229
+ "layers.30.self_attn.k_proj.weight": "model-00003-of-00003.safetensors",
230
+ "layers.30.self_attn.o_proj.weight": "model-00003-of-00003.safetensors",
231
+ "layers.30.self_attn.q_proj.weight": "model-00003-of-00003.safetensors",
232
+ "layers.30.self_attn.v_proj.weight": "model-00003-of-00003.safetensors",
233
+ "layers.31.input_layernorm.weight": "model-00003-of-00003.safetensors",
234
+ "layers.31.mlp.down_proj.weight": "model-00003-of-00003.safetensors",
235
+ "layers.31.mlp.gate_proj.weight": "model-00003-of-00003.safetensors",
236
+ "layers.31.mlp.up_proj.weight": "model-00003-of-00003.safetensors",
237
+ "layers.31.post_attention_layernorm.weight": "model-00003-of-00003.safetensors",
238
+ "layers.31.self_attn.k_proj.weight": "model-00003-of-00003.safetensors",
239
+ "layers.31.self_attn.o_proj.weight": "model-00003-of-00003.safetensors",
240
+ "layers.31.self_attn.q_proj.weight": "model-00003-of-00003.safetensors",
241
+ "layers.31.self_attn.v_proj.weight": "model-00003-of-00003.safetensors",
242
+ "layers.4.input_layernorm.weight": "model-00001-of-00003.safetensors",
243
+ "layers.4.mlp.down_proj.weight": "model-00001-of-00003.safetensors",
244
+ "layers.4.mlp.gate_proj.weight": "model-00001-of-00003.safetensors",
245
+ "layers.4.mlp.up_proj.weight": "model-00001-of-00003.safetensors",
246
+ "layers.4.post_attention_layernorm.weight": "model-00001-of-00003.safetensors",
247
+ "layers.4.self_attn.k_proj.weight": "model-00001-of-00003.safetensors",
248
+ "layers.4.self_attn.o_proj.weight": "model-00001-of-00003.safetensors",
249
+ "layers.4.self_attn.q_proj.weight": "model-00001-of-00003.safetensors",
250
+ "layers.4.self_attn.v_proj.weight": "model-00001-of-00003.safetensors",
251
+ "layers.5.input_layernorm.weight": "model-00001-of-00003.safetensors",
252
+ "layers.5.mlp.down_proj.weight": "model-00001-of-00003.safetensors",
253
+ "layers.5.mlp.gate_proj.weight": "model-00001-of-00003.safetensors",
254
+ "layers.5.mlp.up_proj.weight": "model-00001-of-00003.safetensors",
255
+ "layers.5.post_attention_layernorm.weight": "model-00001-of-00003.safetensors",
256
+ "layers.5.self_attn.k_proj.weight": "model-00001-of-00003.safetensors",
257
+ "layers.5.self_attn.o_proj.weight": "model-00001-of-00003.safetensors",
258
+ "layers.5.self_attn.q_proj.weight": "model-00001-of-00003.safetensors",
259
+ "layers.5.self_attn.v_proj.weight": "model-00001-of-00003.safetensors",
260
+ "layers.6.input_layernorm.weight": "model-00001-of-00003.safetensors",
261
+ "layers.6.mlp.down_proj.weight": "model-00001-of-00003.safetensors",
262
+ "layers.6.mlp.gate_proj.weight": "model-00001-of-00003.safetensors",
263
+ "layers.6.mlp.up_proj.weight": "model-00001-of-00003.safetensors",
264
+ "layers.6.post_attention_layernorm.weight": "model-00001-of-00003.safetensors",
265
+ "layers.6.self_attn.k_proj.weight": "model-00001-of-00003.safetensors",
266
+ "layers.6.self_attn.o_proj.weight": "model-00001-of-00003.safetensors",
267
+ "layers.6.self_attn.q_proj.weight": "model-00001-of-00003.safetensors",
268
+ "layers.6.self_attn.v_proj.weight": "model-00001-of-00003.safetensors",
269
+ "layers.7.input_layernorm.weight": "model-00001-of-00003.safetensors",
270
+ "layers.7.mlp.down_proj.weight": "model-00001-of-00003.safetensors",
271
+ "layers.7.mlp.gate_proj.weight": "model-00001-of-00003.safetensors",
272
+ "layers.7.mlp.up_proj.weight": "model-00001-of-00003.safetensors",
273
+ "layers.7.post_attention_layernorm.weight": "model-00001-of-00003.safetensors",
274
+ "layers.7.self_attn.k_proj.weight": "model-00001-of-00003.safetensors",
275
+ "layers.7.self_attn.o_proj.weight": "model-00001-of-00003.safetensors",
276
+ "layers.7.self_attn.q_proj.weight": "model-00001-of-00003.safetensors",
277
+ "layers.7.self_attn.v_proj.weight": "model-00001-of-00003.safetensors",
278
+ "layers.8.input_layernorm.weight": "model-00001-of-00003.safetensors",
279
+ "layers.8.mlp.down_proj.weight": "model-00001-of-00003.safetensors",
280
+ "layers.8.mlp.gate_proj.weight": "model-00001-of-00003.safetensors",
281
+ "layers.8.mlp.up_proj.weight": "model-00001-of-00003.safetensors",
282
+ "layers.8.post_attention_layernorm.weight": "model-00001-of-00003.safetensors",
283
+ "layers.8.self_attn.k_proj.weight": "model-00001-of-00003.safetensors",
284
+ "layers.8.self_attn.o_proj.weight": "model-00001-of-00003.safetensors",
285
+ "layers.8.self_attn.q_proj.weight": "model-00001-of-00003.safetensors",
286
+ "layers.8.self_attn.v_proj.weight": "model-00001-of-00003.safetensors",
287
+ "layers.9.input_layernorm.weight": "model-00001-of-00003.safetensors",
288
+ "layers.9.mlp.down_proj.weight": "model-00001-of-00003.safetensors",
289
+ "layers.9.mlp.gate_proj.weight": "model-00001-of-00003.safetensors",
290
+ "layers.9.mlp.up_proj.weight": "model-00001-of-00003.safetensors",
291
+ "layers.9.post_attention_layernorm.weight": "model-00001-of-00003.safetensors",
292
+ "layers.9.self_attn.k_proj.weight": "model-00001-of-00003.safetensors",
293
+ "layers.9.self_attn.o_proj.weight": "model-00001-of-00003.safetensors",
294
+ "layers.9.self_attn.q_proj.weight": "model-00001-of-00003.safetensors",
295
+ "layers.9.self_attn.v_proj.weight": "model-00001-of-00003.safetensors",
296
+ "norm.weight": "model-00003-of-00003.safetensors"
297
+ }
298
+ }
modules.json ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ {
3
+ "idx": 0,
4
+ "name": "0",
5
+ "path": "",
6
+ "type": "sentence_transformers.models.Transformer"
7
+ },
8
+ {
9
+ "idx": 1,
10
+ "name": "1",
11
+ "path": "1_Pooling",
12
+ "type": "sentence_transformers.models.Pooling"
13
+ },
14
+ {
15
+ "idx": 2,
16
+ "name": "2",
17
+ "path": "2_SparseEmbedding",
18
+ "type": "sparse_embedding.SparseEmbedding"
19
+ }
20
+ ]
sentence_bert_config.json ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ {
2
+ "max_seq_length": 32768,
3
+ "do_lower_case": false
4
+ }
sparse_embedding.py ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from .zero_neuron import ZeroNeuron
2
+ from sentence_transformers.models import Module
3
+ import torch
4
+
5
+ class SparseEmbedding(Module):
6
+ """ This module should be applied last (after Pooling, Normalize, etc.) """
7
+ config_keys = ["n_in", "init_mean", "init_std", "temperature", "stretch", "eps"]
8
+ def __init__(self,
9
+ n_in: int,
10
+ init_mean: float = 0.5,
11
+ init_std: float = 0.01,
12
+ temperature: float = 1.0,
13
+ stretch: float = 0.1,
14
+ eps: float = 1e-6):
15
+ super(SparseEmbedding, self).__init__()
16
+ self.n_in = n_in
17
+ self.init_mean = init_mean
18
+ self.init_std = init_std
19
+ self.temperature = temperature
20
+ self.stretch = stretch
21
+ self.eps = eps
22
+ self.sparsifyer = ZeroNeuron(
23
+ in_features=n_in,
24
+ out_features=n_in,
25
+ init_mean=init_mean,
26
+ init_std=init_std,
27
+ temperature=temperature,
28
+ stretch=stretch,
29
+ eps=eps
30
+ )
31
+
32
+ def forward(self, features, *args, **kwargs):
33
+ mask = self.sparsifyer(features["sentence_embedding"], dim=kwargs.get("dim", None))
34
+ features["mask"] = mask
35
+ features["sparsity_loss"] = self.sparsifyer.l0_norm(features["sentence_embedding"])
36
+
37
+ return features
38
+
39
+ def save(self, output_path: str):
40
+ self.save_config(output_path)
41
+ torch.save(self.sparsifyer.state_dict(), output_path + "/pytorch_model.bin")
special_tokens_map.json ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "additional_special_tokens": [
3
+ "<unk>",
4
+ "<s>",
5
+ "</s>"
6
+ ],
7
+ "bos_token": {
8
+ "content": "<s>",
9
+ "lstrip": false,
10
+ "normalized": false,
11
+ "rstrip": false,
12
+ "single_word": false
13
+ },
14
+ "eos_token": {
15
+ "content": "</s>",
16
+ "lstrip": false,
17
+ "normalized": false,
18
+ "rstrip": false,
19
+ "single_word": false
20
+ },
21
+ "pad_token": {
22
+ "content": "</s>",
23
+ "lstrip": false,
24
+ "normalized": false,
25
+ "rstrip": false,
26
+ "single_word": false
27
+ },
28
+ "unk_token": {
29
+ "content": "<unk>",
30
+ "lstrip": false,
31
+ "normalized": false,
32
+ "rstrip": false,
33
+ "single_word": false
34
+ }
35
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer.model ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:dadfd56d766715c61d2ef780a525ab43b8e6da4de6865bda3d95fdef5e134055
3
+ size 493443
tokenizer_config.json ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_bos_token": true,
3
+ "add_eos_token": true,
4
+ "add_prefix_space": null,
5
+ "added_tokens_decoder": {
6
+ "0": {
7
+ "content": "<unk>",
8
+ "lstrip": false,
9
+ "normalized": false,
10
+ "rstrip": false,
11
+ "single_word": false,
12
+ "special": true
13
+ },
14
+ "1": {
15
+ "content": "<s>",
16
+ "lstrip": false,
17
+ "normalized": false,
18
+ "rstrip": false,
19
+ "single_word": false,
20
+ "special": true
21
+ },
22
+ "2": {
23
+ "content": "</s>",
24
+ "lstrip": false,
25
+ "normalized": false,
26
+ "rstrip": false,
27
+ "single_word": false,
28
+ "special": true
29
+ }
30
+ },
31
+ "additional_special_tokens": [
32
+ "<unk>",
33
+ "<s>",
34
+ "</s>"
35
+ ],
36
+ "bos_token": "<s>",
37
+ "clean_up_tokenization_spaces": false,
38
+ "eos_token": "</s>",
39
+ "extra_special_tokens": {},
40
+ "legacy": true,
41
+ "model_max_length": 32768,
42
+ "pad_token": "</s>",
43
+ "sp_model_kwargs": {},
44
+ "spaces_between_special_tokens": false,
45
+ "tokenizer_class": "LlamaTokenizer",
46
+ "unk_token": "<unk>",
47
+ "use_default_system_prompt": false
48
+ }
zero_neuron.py ADDED
@@ -0,0 +1,134 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import math
2
+
3
+ import torch
4
+ import torch.nn as nn
5
+ import torch.nn.functional as F
6
+
7
+
8
+ class ZeroNeuron(nn.Module):
9
+ """
10
+ Adapted from: https://github.com/asappresearch/flop/blob/master/flop/hardconcrete.py
11
+ We replace 'self.log_alpha = nn.Parameter...' with something input-dependant: 'self.log_alpha = nn.Linear(...)'
12
+
13
+ >>> import torch
14
+ >>> x = torch.rand(12, 100)
15
+ >>> module = HardConcrete(in_features=100, out_features=100)
16
+ >>> mask = module(x)
17
+ >>> norm = module.l0_norm()
18
+
19
+ """
20
+
21
+ def __init__(self,
22
+ in_features: int,
23
+ out_features: int,
24
+ init_mean: float = 0.5,
25
+ init_std: float = 0.01,
26
+ temperature: float = 1.0,
27
+ stretch: float = 0.1,
28
+ eps: float = 1e-6) -> None:
29
+ """Initialize the HardConcrete module.
30
+
31
+ Parameters
32
+ ----------
33
+ in_features : int
34
+ The features of the input X.
35
+ out_features: int
36
+ The dimension of the sparsity (should be 1 if you want sparsity to be applied on the penultimate dimension of X)
37
+ init_mean : float, optional
38
+ Initialization value for hard concrete parameter,
39
+ by default 0.5.,
40
+ init_std: float, optional
41
+ Used to initialize the hard concrete parameters,
42
+ by default 0.01.
43
+ temperature : float, optional
44
+ Temperature used to control the sharpness of the
45
+ distribution, by default 1.0
46
+ stretch : float, optional
47
+ Stretch the sampled value from [0, 1] to the interval
48
+ [-stretch, 1 + stretch], by default 0.1.
49
+
50
+ """
51
+ super().__init__()
52
+
53
+ self.in_features = in_features
54
+ self.out_features = out_features
55
+ self.limit_l = -stretch
56
+ self.limit_r = 1.0 + stretch
57
+ # we use a low-rank structure to reduce the computation cost.
58
+ if self.out_features > 1:
59
+ self.log_alpha = nn.Sequential(nn.Linear(in_features, 1, bias=False), nn.Linear(1, out_features, bias=False))
60
+ else:
61
+ self.log_alpha = nn.Linear(in_features, 1, bias=False)
62
+
63
+ self.beta = temperature
64
+ self.init_mean = init_mean
65
+ self.init_std = init_std
66
+ self.bias = -self.beta * math.log(-self.limit_l / self.limit_r)
67
+
68
+ self.eps = eps
69
+ self.log_alpha.apply(self.reset_parameters)
70
+
71
+ @torch.no_grad()
72
+ def reset_parameters(self, module):
73
+ """Reset the parameters of this module."""
74
+ mean = math.log(1 - self.init_mean) - math.log(self.init_mean)
75
+ if isinstance(module, nn.Linear):
76
+ module.weight.data.normal_(mean, self.init_std)
77
+
78
+ def l0_norm(self, x: torch.Tensor, log_alpha=None) -> torch.Tensor:
79
+ """Compute the expected L0 norm of this mask.
80
+
81
+ Returns
82
+ -------
83
+ torch.Tensor
84
+ The expected L0 norm.
85
+
86
+ """
87
+ log_alpha = self.log_alpha(x).squeeze(-1) if log_alpha is None else log_alpha
88
+ return (log_alpha + self.bias).sigmoid().mean()
89
+
90
+ def forward(self, x: torch.Tensor, dim=None) -> torch.Tensor: # type: ignore
91
+ """Sample a harconcrete mask.
92
+
93
+ Returns
94
+ -------
95
+ torch.Tensor
96
+ The sampled binary mask
97
+
98
+ """
99
+ log_alpha = self.log_alpha(x).squeeze(-1)
100
+
101
+ if self.training:
102
+ # print(self.log_alpha[0].weight)
103
+ # Sample mask dynamically
104
+ u = torch.rand_like(log_alpha).clamp(self.eps, 1 - self.eps)
105
+ s = F.sigmoid((torch.log(u / (1 - u)) + log_alpha) / self.beta)
106
+ s = s * (self.limit_r - self.limit_l) + self.limit_l
107
+ mask = s.clamp(min=0., max=1.)
108
+
109
+ else:
110
+ # TODO: use this approach when dim is specified, other wise use per-sample / per-token sparsity
111
+ if dim is not None:
112
+ expected_num_zeros = dim
113
+ else:
114
+ # Get expected sparsity
115
+ sparsity_axis = self.out_features if self.out_features != 1 else x.shape[-1]
116
+ # b, s
117
+ expected_num_zeros = sparsity_axis - (log_alpha + self.bias).sigmoid().mean().item()
118
+ num_zeros = round(expected_num_zeros)
119
+ # Approximate expected value of each mask variable z;
120
+ # We use an empirically validated magic number 0.8
121
+ soft_mask = F.sigmoid(log_alpha / self.beta * 0.8)
122
+ # Prune small values to set to 0
123
+ _, indices = torch.topk(soft_mask, k=num_zeros, largest=False)
124
+ soft_mask[..., indices] = 0.
125
+ self.compiled_mask = soft_mask
126
+ mask = self.compiled_mask
127
+
128
+ return mask
129
+
130
+ def extre_repr(self) -> str:
131
+ return f"in_features={self.in_features}, out_features={self.out_features}"
132
+
133
+ def __repr__(self) -> str:
134
+ return "{}({})".format(self.__class__.__name__, self.extre_repr())