wasabibish commited on
Commit
254faee
1 Parent(s): 22b6649

Add new SentenceTransformer model.

Browse files
1_Pooling/config.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "word_embedding_dimension": 768,
3
+ "pooling_mode_cls_token": false,
4
+ "pooling_mode_mean_tokens": true,
5
+ "pooling_mode_max_tokens": false,
6
+ "pooling_mode_mean_sqrt_len_tokens": false,
7
+ "pooling_mode_weightedmean_tokens": false,
8
+ "pooling_mode_lasttoken": false,
9
+ "include_prompt": true
10
+ }
README.md ADDED
@@ -0,0 +1,734 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model: distilbert/distilbert-base-uncased-finetuned-sst-2-english
3
+ library_name: sentence-transformers
4
+ metrics:
5
+ - pearson_cosine
6
+ - spearman_cosine
7
+ - pearson_manhattan
8
+ - spearman_manhattan
9
+ - pearson_euclidean
10
+ - spearman_euclidean
11
+ - pearson_dot
12
+ - spearman_dot
13
+ - pearson_max
14
+ - spearman_max
15
+ pipeline_tag: sentence-similarity
16
+ tags:
17
+ - sentence-transformers
18
+ - sentence-similarity
19
+ - feature-extraction
20
+ - generated_from_trainer
21
+ - dataset_size:302
22
+ - loss:CosineSimilarityLoss
23
+ widget:
24
+ - source_sentence: "interface Input {\n id: number;\n title: string;\n parent_id:\
25
+ \ number | null; \n}\n\ninterface Output extends Input {\n children?: Output[];\
26
+ \ \n}\n\nfunction doJob(inputItems: Input[], parent_id?: number) {\n const outputItems:\
27
+ \ Output[] = [];\n\n for (let i = 0; i < inputItems.length; i++) {\n const\
28
+ \ children = doJob(inputItems.slice(i, inputItems.length), inputItems[i].parent_id)\n\
29
+ \ .filter(i => i.parent_id === parent_id);\n \n outputItems.push({...item,\
30
+ \ children});\n }\n\n return outputItems;\n}"
31
+ sentences:
32
+ - "interface Task {\n id: number;\n title: string;\n parent_id: number\
33
+ \ | null;\n children?: Task[];\n}\n\nfunction buildTaskTree(tasks: Task[]):\
34
+ \ Task[] {\n const tasksMap = tasks.reduce((acc, task) => {\n acc[task.id]\
35
+ \ = { ...task, children: [] };\n return acc;\n }, {} as { [key: number]:\
36
+ \ Task });\n\n const rootTasks: Task[] = [];\n\n tasks.forEach(task => {\n\
37
+ \ const { id, parent_id } = task;\n if (parent_id === null) {\n\
38
+ \ rootTasks.push(tasksMap[id]);\n } else {\n if (tasksMap[parent_id])\
39
+ \ {\n tasksMap[parent_id].children.push(tasksMap[id]);\n \
40
+ \ }\n }\n });\n\n return rootTasks;\n}\n\n// Test the function\
41
+ \ with the provided example\nconst inputTasks: Task[] = [\n { id: 1, title:\
42
+ \ 'Task 1', parent_id: null },\n { id: 2, title: 'Task 2', parent_id: 1 },\n\
43
+ \ { id: 3, title: 'Task 3', parent_id: 1 }\n];\nconst outputTasks: Task[] =\
44
+ \ buildTaskTree(inputTasks);\nconsole.log(outputTasks);\n"
45
+ - "const http = require('http');\n\nasync function checkUrlsStatus(urls) {\n \
46
+ \ const statusObj = {};\n\n const getStatus = async (url) => {\n return\
47
+ \ new Promise((resolve) => {\n http.get(url, (res) => {\n \
48
+ \ resolve(res.statusCode);\n }).on('error', (error) => {\n \
49
+ \ resolve(500); // Internal Server Error\n });\n \
50
+ \ });\n };\n\n await Promise.all(urls.map(async (url) => {\n const\
51
+ \ status = await getStatus(url);\n statusObj[url] = status;\n }));\n\
52
+ \n return statusObj;\n}\n\n// Example\nconst urls = ['https://example.com',\
53
+ \ 'https://google.com'];\ncheckUrlsStatus(urls)\n .then((result) => {\n \
54
+ \ console.log(result);\n })\n .catch((error) => {\n console.error(error);\n\
55
+ \ });\n\nmodule.exports = checkUrlsStatus;\n"
56
+ - "def find_longest_word(words):\n max_length = 0\n longest_word = ''\n\n\
57
+ \ for word in words:\n if len(word) > max_length:\n max_length\
58
+ \ = len(word)\n longest_word = word\n\n return longest_word, max_length\n\
59
+ \n# Test cases\nprint(find_longest_word(['hello', 'world', 'python', 'programming']))\
60
+ \ # Output: ('programming', 11)\nprint(find_longest_word(['short', 'longer',\
61
+ \ 'longest', 'size'])) # Output: ('longest', 7)\n"
62
+ - source_sentence: "// inventory.module.ts\nimport { Module } from '@nestjs/common';\n\
63
+ import { InventoryService } from './inventory.service';\nimport { InventoryController\
64
+ \ } from './inventory.controller';\nimport { TypeOrmModule } from '@nestjs/typeorm';\n\
65
+ import { Product } from './product.entity';\n@Module({\n imports: [TypeOrmModule.forFeature([Product])],\n\
66
+ \ providers: [InventoryService],\n controllers: [InventoryController],\n})\n\
67
+ export class InventoryModule {}\n// inventory.service.ts\nimport { Injectable\
68
+ \ } from '@nestjs/common';\nimport { InjectRepository } from '@nestjs/typeorm';\n\
69
+ import { Product } from './product.entity';\nimport { CreateProductDto, UpdateProductDto\
70
+ \ } from './product.dto';\n\n@Injectable()\nexport class InventoryService {\n\
71
+ \ constructor(\n @InjectRepository(Product)\n private readonly productRepository:\
72
+ \ Repository<Product>,\n ) {}\n\n async createProduct(createProductDto: CreateProductDto):\
73
+ \ Promise<Product> {\n const newProduct = new Product();\n newProduct.name\
74
+ \ = createProductDto.name;\n newProduct.description = createProductDto.description;\n\
75
+ \ newProduct.price = createProductDto.price;\n newProduct.availableQuantity\
76
+ \ = createProductDto.availableQuantity;\n\n return await this.productRepository.save(newProduct);\n\
77
+ \ }\n\n async updateProduct(\n productId: number,\n updateProductDto:\
78
+ \ UpdateProductDto,\n ): Promise<Product> {\n const product = await this.productRepository.findOne(productId);\n\
79
+ \ if (!product) {\n throw new NotFoundException('Product not found');\n\
80
+ \ }\n\n product.name = updateProductDto.name || product.name;\n product.description\
81
+ \ = updateProductDto.description || product.description;\n product.price =\
82
+ \ updateProductDto.price || product.price;\n product.availableQuantity =\n\
83
+ \ updateProductDto.availableQuantity || product.availableQuantity;\n\n \
84
+ \ return await this.productRepository.save(product);\n }\n\n async findAllProducts():\
85
+ \ Promise<Product[]> {\n return await this.productRepository.find();\n }\n\
86
+ \n async getProductById(productId: number): Promise<Product> {\n const product\
87
+ \ = await this.productRepository.findOne(productId);\n if (!product) {\n \
88
+ \ throw new NotFoundException('Product not found');\n }\n return product;\n\
89
+ \ }\n\n async checkProductAvailability(productId: number, quantity: number):\
90
+ \ Promise<boolean> {\n const product = await this.productRepository.findOne(productId);\n\
91
+ \ if (!product) {\n throw new NotFoundException('Product not found');\n\
92
+ \ }\n return product.availableQuantity >= quantity;\n }\n}"
93
+ sentences:
94
+ - "// inventory.dto.ts\nimport { IsInt, IsNotEmpty, IsNumber, IsString, Min } from\
95
+ \ 'class-validator';\n\nexport class ProductDto {\n @IsString()\n @IsNotEmpty()\n\
96
+ \ id: string;\n\n @IsString()\n @IsNotEmpty()\n name: string;\n\n @IsString()\n\
97
+ \ description: string;\n\n @IsNumber()\n @IsNotEmpty()\n price: number;\n\n\
98
+ \ @IsInt()\n @Min(0)\n @IsNotEmpty()\n availableQuantity: number;\n}\n\n//\
99
+ \ inventory.interface.ts\nexport interface Product {\n id: string;\n name: string;\n\
100
+ \ description: string;\n price: number;\n availableQuantity: number;\n}\n\n\
101
+ // inventory.module.ts\nimport { Module } from '@nestjs/common';\nimport { TypeOrmModule\
102
+ \ } from '@nestjs/typeorm';\nimport { InventoryController } from './inventory.controller';\n\
103
+ import { InventoryService } from './inventory.service';\nimport { Product } from\
104
+ \ './product.entity';\n\n@Module({\n imports: [TypeOrmModule.forFeature([Product])],\n\
105
+ \ controllers: [InventoryController],\n providers: [InventoryService]\n})\n\
106
+ export class InventoryModule {} \n\n// product.entity.ts\nimport { Entity, Column,\
107
+ \ PrimaryGeneratedColumn } from 'typeorm';\n\n@Entity()\nexport class Product\
108
+ \ {\n @PrimaryGeneratedColumn()\n id: number;\n\n @Column()\n name: string;\n\
109
+ \n @Column()\n description: string;\n\n @Column('decimal')\n price: number;\n\
110
+ \n @Column()\n availableQuantity: number;\n}\n\n// inventory.controller.ts\n\
111
+ import { Controller, Get, Post, Put, Body, Param } from '@nestjs/common';\nimport\
112
+ \ { InventoryService } from './inventory.service';\nimport { ProductDto } from\
113
+ \ './inventory.dto';\n\n@Controller('inventory')\nexport class InventoryController\
114
+ \ {\n constructor(private readonly inventoryService: InventoryService) {}\n\n\
115
+ \ @Post('add-product')\n async addProduct(@Body() productDto: ProductDto) {\n\
116
+ \ return this.inventoryService.addProduct(productDto);\n }\n\n @Get('products')\n\
117
+ \ async getProducts() {\n return this.inventoryService.getProducts();\n }\n\
118
+ \n @Put('update-quantity/:id')\n async updateQuantity(@Param('id') id: string,\
119
+ \ @Body('quantity') quantity: number) {\n return this.inventoryService.updateQuantity(id,\
120
+ \ quantity);\n }\n}\n\n// inventory.service.ts\nimport { Injectable } from '@nestjs/common';\n\
121
+ import { InjectRepository } from '@nestjs/typeorm';\nimport { Repository } from\
122
+ \ 'typeorm';\nimport { Product } from './product.entity';\nimport { ProductDto\
123
+ \ } from './inventory.dto';\n\n@Injectable()\nexport class InventoryService {\n\
124
+ \ constructor(\n @InjectRepository(Product)\n private productRepository:\
125
+ \ Repository<Product>,\n ) {}\n\n async addProduct(productDto: ProductDto):\
126
+ \ Promise<Product> {\n const newProduct = this.productRepository.create(productDto);\n\
127
+ \ return this.productRepository.save(newProduct);\n }\n\n async getProducts():\
128
+ \ Promise<Product[]> {\n return this.productRepository.find();\n }\n\n async\
129
+ \ updateQuantity(id: string, quantity: number): Promise<Product> {\n const\
130
+ \ product = await this.productRepository.findOne(id);\n if (!product) {\n \
131
+ \ throw new Error('Product not found');\n }\n\n product.availableQuantity\
132
+ \ = quantity;\n return this.productRepository.save(product);\n }\n}\n"
133
+ - "def move_zeros_to_end(lst):\n zero_count = 0\n for i in range(len(lst)):\n\
134
+ \ if lst[i] != 0:\n lst[i], lst[zero_count] = lst[zero_count],\
135
+ \ lst[i]\n zero_count += 1\n\n# Test cases\nlst1 = [0, 1, 0, 3, 12]\n\
136
+ move_zeros_to_end(lst1)\nprint(lst1) # Output: [1, 3, 12, 0, 0]\n\nlst2 = [0,\
137
+ \ 0, 1]\nmove_zeros_to_end(lst2)\nprint(lst2) # Output: [1, 0, 0]\n"
138
+ - "// inventory.dto.ts\nimport { IsInt, IsNotEmpty, IsNumber, IsString, Min } from\
139
+ \ 'class-validator';\n\nexport class ProductDto {\n @IsString()\n @IsNotEmpty()\n\
140
+ \ id: string;\n\n @IsString()\n @IsNotEmpty()\n name: string;\n\n @IsString()\n\
141
+ \ description: string;\n\n @IsNumber()\n @IsNotEmpty()\n price: number;\n\n\
142
+ \ @IsInt()\n @Min(0)\n @IsNotEmpty()\n availableQuantity: number;\n}\n\n//\
143
+ \ inventory.interface.ts\nexport interface Product {\n id: string;\n name: string;\n\
144
+ \ description: string;\n price: number;\n availableQuantity: number;\n}\n\n\
145
+ // inventory.module.ts\nimport { Module } from '@nestjs/common';\nimport { TypeOrmModule\
146
+ \ } from '@nestjs/typeorm';\nimport { InventoryController } from './inventory.controller';\n\
147
+ import { InventoryService } from './inventory.service';\nimport { Product } from\
148
+ \ './product.entity';\n\n@Module({\n imports: [TypeOrmModule.forFeature([Product])],\n\
149
+ \ controllers: [InventoryController],\n providers: [InventoryService]\n})\n\
150
+ export class InventoryModule {} \n\n// product.entity.ts\nimport { Entity, Column,\
151
+ \ PrimaryGeneratedColumn } from 'typeorm';\n\n@Entity()\nexport class Product\
152
+ \ {\n @PrimaryGeneratedColumn()\n id: number;\n\n @Column()\n name: string;\n\
153
+ \n @Column()\n description: string;\n\n @Column('decimal')\n price: number;\n\
154
+ \n @Column()\n availableQuantity: number;\n}\n\n// inventory.controller.ts\n\
155
+ import { Controller, Get, Post, Put, Body, Param } from '@nestjs/common';\nimport\
156
+ \ { InventoryService } from './inventory.service';\nimport { ProductDto } from\
157
+ \ './inventory.dto';\n\n@Controller('inventory')\nexport class InventoryController\
158
+ \ {\n constructor(private readonly inventoryService: InventoryService) {}\n\n\
159
+ \ @Post('add-product')\n async addProduct(@Body() productDto: ProductDto) {\n\
160
+ \ return this.inventoryService.addProduct(productDto);\n }\n\n @Get('products')\n\
161
+ \ async getProducts() {\n return this.inventoryService.getProducts();\n }\n\
162
+ \n @Put('update-quantity/:id')\n async updateQuantity(@Param('id') id: string,\
163
+ \ @Body('quantity') quantity: number) {\n return this.inventoryService.updateQuantity(id,\
164
+ \ quantity);\n }\n}\n\n// inventory.service.ts\nimport { Injectable } from '@nestjs/common';\n\
165
+ import { InjectRepository } from '@nestjs/typeorm';\nimport { Repository } from\
166
+ \ 'typeorm';\nimport { Product } from './product.entity';\nimport { ProductDto\
167
+ \ } from './inventory.dto';\n\n@Injectable()\nexport class InventoryService {\n\
168
+ \ constructor(\n @InjectRepository(Product)\n private productRepository:\
169
+ \ Repository<Product>,\n ) {}\n\n async addProduct(productDto: ProductDto):\
170
+ \ Promise<Product> {\n const newProduct = this.productRepository.create(productDto);\n\
171
+ \ return this.productRepository.save(newProduct);\n }\n\n async getProducts():\
172
+ \ Promise<Product[]> {\n return this.productRepository.find();\n }\n\n async\
173
+ \ updateQuantity(id: string, quantity: number): Promise<Product> {\n const\
174
+ \ product = await this.productRepository.findOne(id);\n if (!product) {\n \
175
+ \ throw new Error('Product not found');\n }\n\n product.availableQuantity\
176
+ \ = quantity;\n return this.productRepository.save(product);\n }\n}\n"
177
+ - source_sentence: "// wage-input.dto.ts\nimport { IsNumber, IsPositive } from 'class-validator';\n\
178
+ \nexport class WageInputDto {\n @IsNumber()\n @IsPositive()\n hourlyWage: number;\n\
179
+ \n @IsNumber()\n @IsPositive()\n hoursWorked: number;\n}\n\n// It will handle\
180
+ \ the input validation too.\n\n\n// employee.controller.ts\nimport { Body, Controller,\
181
+ \ Post } from '@nestjs/common';\nimport { WageInputDto } from './dto/wage-input.dto';\n\
182
+ import { EmployeeService } from './employee.service';\n\n@Controller('employee')\n\
183
+ export class EmployeeController {\n constructor(private readonly employeeService:\
184
+ \ EmployeeService) {}\n\n @Post('/wage')\n async getWage(@Body() input: WageInputDto)\
185
+ \ {\n return this.employeeService.getWage(input);\n }\n}\n\n// employee.service.ts\n\
186
+ import { Injectable } from '@nestjs/common';\nimport { WageInputDto } from './dto/wage-input.dto';\n\
187
+ \nconst WEEKLY_HOURS = 40;\n\n@Injectable()\nexport class EmployeeService {\n\
188
+ \ async getWage(input: WageInputDto) {\n let weeklyHours = 0;\n let overTimeHours\
189
+ \ = 0;\n let weeklyWage = 0;\n\n const hasDoneOverTime = input.hoursWorked\
190
+ \ > WEEKLY_HOURS;\n\n if (hasDoneOverTime) {\n weeklyHours = WEEKLY_HOURS;\n\
191
+ \ overTimeHours = input.hoursWorked - WEEKLY_HOURS;\n } else {\n \
192
+ \ weeklyHours = input.hoursWorked;\n }\n\n weeklyWage = weeklyHours * input.hourlyWage;\n\
193
+ \n if (hasDoneOverTime) {\n weeklyWage = weeklyWage + overTimeHours *\
194
+ \ (input.hourlyWage * 1.5);\n }\n\n return { weeklyWage };\n }\n}"
195
+ sentences:
196
+ - "import { Controller, Post, Body, HttpException, HttpStatus } from '@nestjs/common';\n\
197
+ \ninterface WeeklyWageInput {\n hourlyWage: number;\n hoursWorked: number;\n\
198
+ }\n\n@Controller('calculate-weekly-wage')\nexport class WeeklyWageController {\n\
199
+ \ @Post()\n calculateWeeklyWage(@Body() data: WeeklyWageInput): { weeklyWage:\
200
+ \ number } {\n // Input validation\n if (data.hourlyWage <= 0 || data.hoursWorked\
201
+ \ <= 0 || !Number.isInteger(data.hoursWorked)) {\n throw new HttpException('Invalid\
202
+ \ input. Hourly wage must be positive and hours worked must be a positive integer',\
203
+ \ HttpStatus.BAD_REQUEST);\n }\n\n const regularHours = Math.min(data.hoursWorked,\
204
+ \ 40);\n const overtimeHours = Math.max(data.hoursWorked - 40, 0);\n\n const\
205
+ \ weeklyWage = (regularHours * data.hourlyWage) + (overtimeHours * (1.5 * data.hourlyWage));\n\
206
+ \n return { weeklyWage };\n }\n}\n"
207
+ - "import { Pipe, PipeTransform } from '@angular/core';\n\n@Pipe({\n name: 'orderBy'\n\
208
+ })\nexport class OrderByPipe implements PipeTransform {\n transform(array: any[],\
209
+ \ key: string, order: 'asc' | 'desc'): any[] {\n if (!Array.isArray(array)\
210
+ \ || !key || (order !== 'asc' && order !== 'desc')) {\n console.error('Invalid\
211
+ \ input data');\n return array;\n }\n\n const compareFn = (a: any,\
212
+ \ b: any): number => {\n if (a[key] < b[key]) {\n return order ===\
213
+ \ 'asc' ? -1 : 1;\n }\n if (a[key] > b[key]) {\n return order\
214
+ \ === 'asc' ? 1 : -1;\n }\n return 0;\n };\n\n return array.slice().sort(compareFn);\n\
215
+ \ }\n}\n"
216
+ - "public class PalindromeChecker {\n public static boolean isPalindrome(String\
217
+ \ str) {\n str = str.toLowerCase().replaceAll(\"[^a-zA-Z0-9]\", \"\");\n\
218
+ \ int left = 0;\n int right = str.length() - 1;\n \n \
219
+ \ while (left < right) {\n if (str.charAt(left) != str.charAt(right))\
220
+ \ {\n return false;\n }\n left++;\n \
221
+ \ right--;\n }\n \n return true;\n }\n \n \
222
+ \ public static void main(String[] args) {\n String input1 = \"A man, a\
223
+ \ plan, a canal: Panama\";\n String input2 = \"race a car\";\n \n\
224
+ \ System.out.println(\"Input: '\" + input1 + \"' Output: \" + isPalindrome(input1));\n\
225
+ \ System.out.println(\"Input: '\" + input2 + \"' Output: \" + isPalindrome(input2));\n\
226
+ \ }\n}\n"
227
+ - source_sentence: 'FROM python:3.8
228
+
229
+ WORKDIR /app
230
+
231
+
232
+ COPY helloworld.py .
233
+
234
+ RUN pip install --no-cache-dir -r requirements.txt
235
+
236
+ CMD ["python", "helloworld.py"]
237
+
238
+
239
+
240
+ ## PYTHON PROGRAM
241
+
242
+ helloworld.py
243
+
244
+ print("Hello, World!")
245
+
246
+
247
+
248
+ ## BUILD COMMAND
249
+
250
+ docker build -t "python:helloworld" .
251
+
252
+ docker run -itd --name python python:helloworld'
253
+ sentences:
254
+ - '# Use a slim Python base image for optimization
255
+
256
+ FROM python:3.9-slim
257
+
258
+
259
+ # Set the working directory inside the container
260
+
261
+ WORKDIR /app
262
+
263
+
264
+ # Copy the Python script into the container
265
+
266
+ COPY hello.py /app/hello.py
267
+
268
+
269
+ # Define the command to run the Python script
270
+
271
+ CMD ["python", "/app/hello.py"]
272
+
273
+ '
274
+ - "import java.util.HashMap;\n\npublic class Solution {\n public int[] twoSum(int[]\
275
+ \ nums, int target) {\n HashMap<Integer, Integer> map = new HashMap<>();\n\
276
+ \n for (int i = 0; i < nums.length; i++) {\n int complement\
277
+ \ = target - nums[i];\n if (map.containsKey(complement)) {\n \
278
+ \ return new int[]{map.get(complement), i};\n }\n \
279
+ \ map.put(nums[i], i);\n }\n\n return new int[]{};\n }\n}\n\
280
+ \n// Example\nint[] array = new int[]{2, 7, 11, 15};\nint target = 9;\nSolution\
281
+ \ solution = new Solution();\nint[] result = solution.twoSum(array, target);\n"
282
+ - "function stripHtmlTags(input) {\n if (!input) return '';\n\n const tagRegex\
283
+ \ = /<[^>]*>/g;\n return input.replace(tagRegex, '');\n}\n"
284
+ - source_sentence: "def move_zeroes(nums):\n count = 0\n for i in range(len(nums)):\n\
285
+ \ if nums[i] != 0:\n nums[count], nums[i]= nums[i], nums[count]\n \
286
+ \ count += 1\n for i in range(count, len(nums)):\n nums[i] =0\n\ninput =\
287
+ \ [int(x) for x in input(\"Enter integers separated by spaces: \").split()]\n\
288
+ move_zeroes(input)\n\nprint(input)"
289
+ sentences:
290
+ - "import 'package:flutter/material.dart';\nimport 'package:firebase_core/firebase_core.dart';\n\
291
+ import 'package:firebase_auth/firebase_auth.dart';\nimport 'package:firebase_database/firebase_database.dart';\n\
292
+ \nvoid main() async {\n WidgetsFlutterBinding.ensureInitialized();\n await Firebase.initializeApp();\n\
293
+ \ runApp(MyApp());\n}\n\nclass MyApp extends StatelessWidget {\n final databaseRef\
294
+ \ = FirebaseDatabase.instance.reference().child('messages');\n\n @override\n\
295
+ \ Widget build(BuildContext context) {\n return MaterialApp(\n home:\
296
+ \ Scaffold(\n appBar: AppBar(\n title: Text('Real-Time Messages'),\n\
297
+ \ ),\n body: MessagesList(databaseRef: databaseRef),\n floatingActionButton:\
298
+ \ AddMessageButton(databaseRef: databaseRef),\n ),\n );\n }\n}\n\nclass\
299
+ \ MessagesList extends StatelessWidget {\n final DatabaseReference databaseRef;\n\
300
+ \n MessagesList({required this.databaseRef});\n\n @override\n Widget build(BuildContext\
301
+ \ context) {\n return StreamBuilder(\n stream: databaseRef.orderByChild('timestamp').onValue,\n\
302
+ \ builder: (context, snapshot) {\n if (snapshot.hasError) {\n \
303
+ \ return Text('Error: ${snapshot.error}');\n }\n\n if (!snapshot.hasData)\
304
+ \ {\n return Center(child: CircularProgressIndicator());\n }\n\
305
+ \n List<Message> messages = [];\n snapshot.data!.snapshot.value.forEach((key,\
306
+ \ value) {\n messages.add(Message.fromMap(value));\n });\n \
307
+ \ messages.sort((a, b) => a.timestamp.compareTo(b.timestamp));\n\n \
308
+ \ return ListView.builder(\n itemCount: messages.length,\n itemBuilder:\
309
+ \ (context, index) {\n return ListTile(\n title: Text(messages[index].text),\n\
310
+ \ );\n },\n );\n },\n );\n }\n}\n\nclass AddMessageButton\
311
+ \ extends StatelessWidget {\n final DatabaseReference databaseRef;\n\n AddMessageButton({required\
312
+ \ this.databaseRef});\n\n @override\n Widget build(BuildContext context) {\n\
313
+ \ return FloatingActionButton(\n onPressed: () {\n databaseRef.push().set({\n\
314
+ \ 'text': 'New Message',\n 'timestamp': DateTime.now().millisecondsSinceEpoch\n\
315
+ \ });\n },\n child: Icon(Icons.add),\n );\n }\n}\n\nclass\
316
+ \ Message {\n final String text;\n final int timestamp;\n\n Message({required\
317
+ \ this.text, required this.timestamp});\n\n factory Message.fromMap(Map<dynamic,\
318
+ \ dynamic> map) {\n return Message(\n text: map['text'],\n timestamp:\
319
+ \ map['timestamp'],\n );\n }\n}\n"
320
+ - "using System;\nusing System.Collections.Generic;\n\nclass BracketChecker\n{\n\
321
+ \ private readonly Dictionary<char, char> bracketPairs = new Dictionary<char,\
322
+ \ char>\n {\n { '(', ')' },\n { '[', ']' },\n { '{', '}'\
323
+ \ }\n };\n\n public bool CheckBalancedBrackets(string input)\n {\n \
324
+ \ if (string.IsNullOrEmpty(input))\n {\n return true;\n\
325
+ \ }\n\n Stack<char> stack = new Stack<char>();\n\n foreach\
326
+ \ (char c in input)\n {\n if (bracketPairs.ContainsValue(c))\n\
327
+ \ {\n if (stack.Count == 0 || bracketPairs[stack.Peek()]\
328
+ \ != c)\n {\n return false;\n \
329
+ \ }\n stack.Pop();\n }\n else if (bracketPairs.ContainsKey(c))\n\
330
+ \ {\n stack.Push(c);\n }\n }\n\n \
331
+ \ return stack.Count == 0;\n }\n}\n\nclass Program\n{\n static void\
332
+ \ Main()\n {\n BracketChecker bracketChecker = new BracketChecker();\n\
333
+ \n string input1 = \"(a+[b*c]-{d/e})\";\n Console.WriteLine(\"Input:\
334
+ \ \\\"{0}\\\"\", input1);\n Console.WriteLine(\"Output: {0}\\n\", bracketChecker.CheckBalancedBrackets(input1));\n\
335
+ \n string input2 = \"(a+[b*c)-{d/e}]\";\n Console.WriteLine(\"Input:\
336
+ \ \\\"{0}\\\"\", input2);\n Console.WriteLine(\"Output: {0}\", bracketChecker.CheckBalancedBrackets(input2));\n\
337
+ \ }\n}\n"
338
+ - "def move_zeros_to_end(lst):\n zero_count = 0\n for i in range(len(lst)):\n\
339
+ \ if lst[i] != 0:\n lst[i], lst[zero_count] = lst[zero_count],\
340
+ \ lst[i]\n zero_count += 1\n\n# Test cases\nlst1 = [0, 1, 0, 3, 12]\n\
341
+ move_zeros_to_end(lst1)\nprint(lst1) # Output: [1, 3, 12, 0, 0]\n\nlst2 = [0,\
342
+ \ 0, 1]\nmove_zeros_to_end(lst2)\nprint(lst2) # Output: [1, 0, 0]\n"
343
+ model-index:
344
+ - name: SentenceTransformer based on distilbert/distilbert-base-uncased-finetuned-sst-2-english
345
+ results:
346
+ - task:
347
+ type: semantic-similarity
348
+ name: Semantic Similarity
349
+ dataset:
350
+ name: Unknown
351
+ type: unknown
352
+ metrics:
353
+ - type: pearson_cosine
354
+ value: 0.9000341656513303
355
+ name: Pearson Cosine
356
+ - type: spearman_cosine
357
+ value: 0.9013693287916293
358
+ name: Spearman Cosine
359
+ - type: pearson_manhattan
360
+ value: 0.8619949591168187
361
+ name: Pearson Manhattan
362
+ - type: spearman_manhattan
363
+ value: 0.8020438201628594
364
+ name: Spearman Manhattan
365
+ - type: pearson_euclidean
366
+ value: 0.868483180326987
367
+ name: Pearson Euclidean
368
+ - type: spearman_euclidean
369
+ value: 0.8234464507775442
370
+ name: Spearman Euclidean
371
+ - type: pearson_dot
372
+ value: 0.8494699061913786
373
+ name: Pearson Dot
374
+ - type: spearman_dot
375
+ value: 0.8947516297094024
376
+ name: Spearman Dot
377
+ - type: pearson_max
378
+ value: 0.9000341656513303
379
+ name: Pearson Max
380
+ - type: spearman_max
381
+ value: 0.9013693287916293
382
+ name: Spearman Max
383
+ ---
384
+
385
+ # SentenceTransformer based on distilbert/distilbert-base-uncased-finetuned-sst-2-english
386
+
387
+ This is a [sentence-transformers](https://www.SBERT.net) model finetuned from [distilbert/distilbert-base-uncased-finetuned-sst-2-english](https://huggingface.co/distilbert/distilbert-base-uncased-finetuned-sst-2-english). It maps sentences & paragraphs to a 768-dimensional dense vector space and can be used for semantic textual similarity, semantic search, paraphrase mining, text classification, clustering, and more.
388
+
389
+ ## Model Details
390
+
391
+ ### Model Description
392
+ - **Model Type:** Sentence Transformer
393
+ - **Base model:** [distilbert/distilbert-base-uncased-finetuned-sst-2-english](https://huggingface.co/distilbert/distilbert-base-uncased-finetuned-sst-2-english) <!-- at revision 714eb0fa89d2f80546fda750413ed43d93601a13 -->
394
+ - **Maximum Sequence Length:** 512 tokens
395
+ - **Output Dimensionality:** 768 tokens
396
+ - **Similarity Function:** Cosine Similarity
397
+ <!-- - **Training Dataset:** Unknown -->
398
+ <!-- - **Language:** Unknown -->
399
+ <!-- - **License:** Unknown -->
400
+
401
+ ### Model Sources
402
+
403
+ - **Documentation:** [Sentence Transformers Documentation](https://sbert.net)
404
+ - **Repository:** [Sentence Transformers on GitHub](https://github.com/UKPLab/sentence-transformers)
405
+ - **Hugging Face:** [Sentence Transformers on Hugging Face](https://huggingface.co/models?library=sentence-transformers)
406
+
407
+ ### Full Model Architecture
408
+
409
+ ```
410
+ SentenceTransformer(
411
+ (0): Transformer({'max_seq_length': 512, 'do_lower_case': False}) with Transformer model: DistilBertModel
412
+ (1): Pooling({'word_embedding_dimension': 768, 'pooling_mode_cls_token': False, 'pooling_mode_mean_tokens': True, 'pooling_mode_max_tokens': False, 'pooling_mode_mean_sqrt_len_tokens': False, 'pooling_mode_weightedmean_tokens': False, 'pooling_mode_lasttoken': False, 'include_prompt': True})
413
+ )
414
+ ```
415
+
416
+ ## Usage
417
+
418
+ ### Direct Usage (Sentence Transformers)
419
+
420
+ First install the Sentence Transformers library:
421
+
422
+ ```bash
423
+ pip install -U sentence-transformers
424
+ ```
425
+
426
+ Then you can load this model and run inference.
427
+ ```python
428
+ from sentence_transformers import SentenceTransformer
429
+
430
+ # Download from the 🤗 Hub
431
+ model = SentenceTransformer("wasabibish/similarity-code-ai-generated")
432
+ # Run inference
433
+ sentences = [
434
+ 'def move_zeroes(nums):\n count = 0\n for i in range(len(nums)):\n if nums[i] != 0:\n nums[count], nums[i]= nums[i], nums[count]\n count += 1\n for i in range(count, len(nums)):\n nums[i] =0\n\ninput = [int(x) for x in input("Enter integers separated by spaces: ").split()]\nmove_zeroes(input)\n\nprint(input)',
435
+ 'def move_zeros_to_end(lst):\n zero_count = 0\n for i in range(len(lst)):\n if lst[i] != 0:\n lst[i], lst[zero_count] = lst[zero_count], lst[i]\n zero_count += 1\n\n# Test cases\nlst1 = [0, 1, 0, 3, 12]\nmove_zeros_to_end(lst1)\nprint(lst1) # Output: [1, 3, 12, 0, 0]\n\nlst2 = [0, 0, 1]\nmove_zeros_to_end(lst2)\nprint(lst2) # Output: [1, 0, 0]\n',
436
+ 'using System;\nusing System.Collections.Generic;\n\nclass BracketChecker\n{\n private readonly Dictionary<char, char> bracketPairs = new Dictionary<char, char>\n {\n { \'(\', \')\' },\n { \'[\', \']\' },\n { \'{\', \'}\' }\n };\n\n public bool CheckBalancedBrackets(string input)\n {\n if (string.IsNullOrEmpty(input))\n {\n return true;\n }\n\n Stack<char> stack = new Stack<char>();\n\n foreach (char c in input)\n {\n if (bracketPairs.ContainsValue(c))\n {\n if (stack.Count == 0 || bracketPairs[stack.Peek()] != c)\n {\n return false;\n }\n stack.Pop();\n }\n else if (bracketPairs.ContainsKey(c))\n {\n stack.Push(c);\n }\n }\n\n return stack.Count == 0;\n }\n}\n\nclass Program\n{\n static void Main()\n {\n BracketChecker bracketChecker = new BracketChecker();\n\n string input1 = "(a+[b*c]-{d/e})";\n Console.WriteLine("Input: \\"{0}\\"", input1);\n Console.WriteLine("Output: {0}\\n", bracketChecker.CheckBalancedBrackets(input1));\n\n string input2 = "(a+[b*c)-{d/e}]";\n Console.WriteLine("Input: \\"{0}\\"", input2);\n Console.WriteLine("Output: {0}", bracketChecker.CheckBalancedBrackets(input2));\n }\n}\n',
437
+ ]
438
+ embeddings = model.encode(sentences)
439
+ print(embeddings.shape)
440
+ # [3, 768]
441
+
442
+ # Get the similarity scores for the embeddings
443
+ similarities = model.similarity(embeddings, embeddings)
444
+ print(similarities.shape)
445
+ # [3, 3]
446
+ ```
447
+
448
+ <!--
449
+ ### Direct Usage (Transformers)
450
+
451
+ <details><summary>Click to see the direct usage in Transformers</summary>
452
+
453
+ </details>
454
+ -->
455
+
456
+ <!--
457
+ ### Downstream Usage (Sentence Transformers)
458
+
459
+ You can finetune this model on your own dataset.
460
+
461
+ <details><summary>Click to expand</summary>
462
+
463
+ </details>
464
+ -->
465
+
466
+ <!--
467
+ ### Out-of-Scope Use
468
+
469
+ *List how the model may foreseeably be misused and address what users ought not to do with the model.*
470
+ -->
471
+
472
+ ## Evaluation
473
+
474
+ ### Metrics
475
+
476
+ #### Semantic Similarity
477
+
478
+ * Evaluated with [<code>EmbeddingSimilarityEvaluator</code>](https://sbert.net/docs/package_reference/sentence_transformer/evaluation.html#sentence_transformers.evaluation.EmbeddingSimilarityEvaluator)
479
+
480
+ | Metric | Value |
481
+ |:-------------------|:-----------|
482
+ | pearson_cosine | 0.9 |
483
+ | spearman_cosine | 0.9014 |
484
+ | pearson_manhattan | 0.862 |
485
+ | spearman_manhattan | 0.802 |
486
+ | pearson_euclidean | 0.8685 |
487
+ | spearman_euclidean | 0.8234 |
488
+ | pearson_dot | 0.8495 |
489
+ | spearman_dot | 0.8948 |
490
+ | pearson_max | 0.9 |
491
+ | **spearman_max** | **0.9014** |
492
+
493
+ <!--
494
+ ## Bias, Risks and Limitations
495
+
496
+ *What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model.*
497
+ -->
498
+
499
+ <!--
500
+ ### Recommendations
501
+
502
+ *What are recommendations with respect to the foreseeable issues? For example, filtering explicit content.*
503
+ -->
504
+
505
+ ## Training Details
506
+
507
+ ### Training Dataset
508
+
509
+ #### Unnamed Dataset
510
+
511
+
512
+ * Size: 302 training samples
513
+ * Columns: <code>sentence1</code>, <code>sentence2</code>, and <code>score</code>
514
+ * Approximate statistics based on the first 302 samples:
515
+ | | sentence1 | sentence2 | score |
516
+ |:--------|:------------------------------------------------------------------------------------|:------------------------------------------------------------------------------------|:---------------------------------------------------------------|
517
+ | type | string | string | float |
518
+ | details | <ul><li>min: 3 tokens</li><li>mean: 206.43 tokens</li><li>max: 512 tokens</li></ul> | <ul><li>min: 27 tokens</li><li>mean: 244.9 tokens</li><li>max: 512 tokens</li></ul> | <ul><li>min: 0.0</li><li>mean: 0.29</li><li>max: 0.9</li></ul> |
519
+ * Samples:
520
+ | sentence1 | sentence2 | score |
521
+ |:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:-----------------|
522
+ | <code>from django.views.generic import ListView<br><br>class PersonListView(ListView):<br> model = Person<br> template_name = 'person_list.html'<br><br> def get_queryset(self):<br> return Person.objects.filter(birthdate__year__lte=2005)</code> | <code>from myapp.models import Customer # Import the Customer model from your Django app<br><br>def get_customers_with_zip_code_starting_with_123():<br> customers = Customer.objects.filter(zip_code__startswith='123').values() # Query to filter customers with zip_code starting with '123'<br> return list(customers) # Return a list of dictionaries for matching records<br></code> | <code>0.4</code> |
523
+ | <code><div class="content-box"><br> <p>Welcome to our website!</p><br></div><br><style><br> .content-box {<br> margin: 20;<br> background-colour: #00G;<br> }<br></style></code> | <code>function createSentence(words, maxChars) {<br> if (words.length === 0 || maxChars < 1) {<br> return "";<br> }<br><br> let sentence = "";<br> let currentLength = 0;<br><br> for (let i = 0; i < words.length; i++) {<br> if (sentence.length + words[i].length + 1 <= maxChars) {<br> sentence += words[i] + " ";<br> currentLength += words[i].length + 1;<br> } else {<br> break;<br> }<br> }<br><br> if (sentence.length > 0) {<br> sentence = sentence.trim() + ".";<br> }<br><br> return sentence;<br>}<br><br>// Test the function with the example<br>const words = ['hello', 'world', 'this', 'is', 'a', 'test'];<br>const maxChars = 20;<br>console.log(createSentence(words, maxChars)); // Output: 'hello world this.'<br></code> | <code>0.1</code> |
524
+ | <code>AAAAAA</code> | <code>#include <atlstr.h><br>#include <vector><br><br>class KMP {<br>public:<br> std::vector<int> findPatternIndices(const CString& text, const CString& pattern) {<br> std::vector<int> indices;<br> if (pattern.IsEmpty() || text.IsEmpty()) {<br> return indices;<br> }<br><br> std::vector<int> lps = computeLPSArray(pattern);<br><br> int i = 0, j = 0;<br> while (i < text.GetLength()) {<br> if (pattern[j] == text[i]) {<br> j++;<br> i++;<br> }<br><br> if (j == pattern.GetLength()) {<br> indices.push_back(i - j);<br> j = lps[j - 1];<br> } else if (i < text.GetLength() && pattern[j] != text[i]) {<br> if (j != 0) {<br> j = lps[j - 1];<br> } else {<br> i++;<br> }<br> }<br> }<br><br> return indices;<br> }<br><br>private:<br> std::vector<int> computeLPSArray(const CString& pattern) {<br> int len = 0;<br> std::vector<int> lps(pattern.GetLength(), 0);<br> <br> int i = 1;<br> while (i < pattern.GetLength()) {<br> if (pattern[i] == pattern[len]) {<br> len++;<br> lps[i] = len;<br> i++;<br> } else {<br> if (len != 0) {<br> len = lps[len - 1];<br> } else {<br> lps[i] = 0;<br> i++;<br> }<br> }<br> }<br><br> return lps;<br> }<br>};<br><br>void testKMP() {<br> KMP kmp;<br> <br> CString text1 = "ABABDABACDABABCABAB";<br> CString pattern1 = "ABABCABAB";<br> std::vector<int> result1 = kmp.findPatternIndices(text1, pattern1);<br> OutputDebugString("Input: text='ABABDABACDABABCABAB', pattern='ABABCABAB' -> Output: [");<br> for (int i = 0; i < result1.size(); i++) {<br> OutputDebugString(result1[i]);<br> if (i < result1.size() - 1) {<br> OutputDebugString(",");<br> }<br> }<br> OutputDebugString("]\n");<br><br> CString text2 = "AAAAA";<br> CString pattern2 = "AAA";<br> std::vector<int> result2 = kmp.findPatternIndices(text2, pattern2);<br> OutputDebugString("Input: text='AAAAA', pattern='AAA' -> Output: [");<br> for (int i = 0; i < result2.size(); i++) {<br> OutputDebugString(result2[i]);<br> if (i < result2.size() - 1) {<br> OutputDebugString(",");<br> }<br> }<br> OutputDebugString("]\n");<br>}<br></code> | <code>0.0</code> |
525
+ * Loss: [<code>CosineSimilarityLoss</code>](https://sbert.net/docs/package_reference/sentence_transformer/losses.html#cosinesimilarityloss) with these parameters:
526
+ ```json
527
+ {
528
+ "loss_fct": "torch.nn.modules.loss.MSELoss"
529
+ }
530
+ ```
531
+
532
+ ### Evaluation Dataset
533
+
534
+ #### Unnamed Dataset
535
+
536
+
537
+ * Size: 76 evaluation samples
538
+ * Columns: <code>sentence1</code>, <code>sentence2</code>, and <code>score</code>
539
+ * Approximate statistics based on the first 76 samples:
540
+ | | sentence1 | sentence2 | score |
541
+ |:--------|:------------------------------------------------------------------------------------|:-------------------------------------------------------------------------------------|:---------------------------------------------------------------|
542
+ | type | string | string | float |
543
+ | details | <ul><li>min: 5 tokens</li><li>mean: 216.92 tokens</li><li>max: 512 tokens</li></ul> | <ul><li>min: 54 tokens</li><li>mean: 254.78 tokens</li><li>max: 512 tokens</li></ul> | <ul><li>min: 0.0</li><li>mean: 0.33</li><li>max: 0.9</li></ul> |
544
+ * Samples:
545
+ | sentence1 | sentence2 | score |
546
+ |:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:-----------------|
547
+ | <code>function stripHtmlTags(str) {<br> return str.replace(/<[^>]*>/g, '');<br>}<br><br>const input = '<p>Hello <em>World</em>!</p>';<br><br>const output = stripHtmlTags(input);<br><br>console.log(output);</code> | <code>function stripHtmlTags(input) {<br> if (!input) return '';<br><br> const tagRegex = /<[^>]*>/g;<br> return input.replace(tagRegex, '');<br>}<br></code> | <code>0.6</code> |
548
+ | <code><?php<br>function getTopThreeWords($text) {<br>// Remove punctuation and convert to lowercase<br>$words = str_word_count(strtolower(preg_replace('/[^\p{L}\p{N}\s]/u', ' ', $text)), 1);<br><br>// Count the frequency of each word<br>$wordFrequency = array_count_values($words);<br><br>// Sort the words by frequency in descending order<br>arsort($wordFrequency);<br><br>// Get the top three words<br>$topThreeWords = array_slice($wordFrequency, 0, 3, true);<br><br>// Format the output<br>$output = [];<br>foreach ($topThreeWords as $word => $count) {<br>$output[] = "('$word', $count)";<br>}<br><br>return '[' . implode(', ', $output) . ']';<br>}<br><br>// Example usage:<br>$inputText = "The quick brown fox jumps over the lazy dog. The dog was lazy!";<br>echo getTopThreeWords($inputText);<br>?></code> | <code><?php<br><br>function countTopWords($inputString) {<br> // Convert the input string to lowercase and remove punctuation<br> $cleanString = preg_replace("/[\W_]+/", " ", strtolower($inputString));<br><br> // Split the string into an array of words<br> $words = explode(" ", $cleanString);<br><br> // Count the frequency of each word<br> $wordCount = array_count_values($words);<br><br> // Sort the words by frequency in descending order<br> arsort($wordCount);<br><br> // Get the top three most common words<br> $topWords = array_slice($wordCount, 0, 3);<br><br> // Format the output as an array of tuples<br> $output = [];<br> foreach ($topWords as $word => $count) {<br> $output[] = [$word, $count];<br> }<br><br> return $output;<br>}<br><br>// Test the function with the example input<br>$inputString = "The quick brown fox jumps over the lazy dog. The dog was lazy!";<br>$output = countTopWords($inputString);<br>print_r($output);<br><br>?><br></code> | <code>0.3</code> |
549
+ | <code>AAAAAA</code> | <code>#include <atlstr.h><br>#include <vector><br><br>class KMP {<br>public:<br> std::vector<int> findPatternIndices(const CString& text, const CString& pattern) {<br> std::vector<int> indices;<br> if (pattern.IsEmpty() || text.IsEmpty()) {<br> return indices;<br> }<br><br> std::vector<int> lps = computeLPSArray(pattern);<br><br> int i = 0, j = 0;<br> while (i < text.GetLength()) {<br> if (pattern[j] == text[i]) {<br> j++;<br> i++;<br> }<br><br> if (j == pattern.GetLength()) {<br> indices.push_back(i - j);<br> j = lps[j - 1];<br> } else if (i < text.GetLength() && pattern[j] != text[i]) {<br> if (j != 0) {<br> j = lps[j - 1];<br> } else {<br> i++;<br> }<br> }<br> }<br><br> return indices;<br> }<br><br>private:<br> std::vector<int> computeLPSArray(const CString& pattern) {<br> int len = 0;<br> std::vector<int> lps(pattern.GetLength(), 0);<br> <br> int i = 1;<br> while (i < pattern.GetLength()) {<br> if (pattern[i] == pattern[len]) {<br> len++;<br> lps[i] = len;<br> i++;<br> } else {<br> if (len != 0) {<br> len = lps[len - 1];<br> } else {<br> lps[i] = 0;<br> i++;<br> }<br> }<br> }<br><br> return lps;<br> }<br>};<br><br>void testKMP() {<br> KMP kmp;<br> <br> CString text1 = "ABABDABACDABABCABAB";<br> CString pattern1 = "ABABCABAB";<br> std::vector<int> result1 = kmp.findPatternIndices(text1, pattern1);<br> OutputDebugString("Input: text='ABABDABACDABABCABAB', pattern='ABABCABAB' -> Output: [");<br> for (int i = 0; i < result1.size(); i++) {<br> OutputDebugString(result1[i]);<br> if (i < result1.size() - 1) {<br> OutputDebugString(",");<br> }<br> }<br> OutputDebugString("]\n");<br><br> CString text2 = "AAAAA";<br> CString pattern2 = "AAA";<br> std::vector<int> result2 = kmp.findPatternIndices(text2, pattern2);<br> OutputDebugString("Input: text='AAAAA', pattern='AAA' -> Output: [");<br> for (int i = 0; i < result2.size(); i++) {<br> OutputDebugString(result2[i]);<br> if (i < result2.size() - 1) {<br> OutputDebugString(",");<br> }<br> }<br> OutputDebugString("]\n");<br>}<br></code> | <code>0.0</code> |
550
+ * Loss: [<code>CosineSimilarityLoss</code>](https://sbert.net/docs/package_reference/sentence_transformer/losses.html#cosinesimilarityloss) with these parameters:
551
+ ```json
552
+ {
553
+ "loss_fct": "torch.nn.modules.loss.MSELoss"
554
+ }
555
+ ```
556
+
557
+ ### Training Hyperparameters
558
+ #### Non-Default Hyperparameters
559
+
560
+ - `eval_strategy`: steps
561
+ - `weight_decay`: 0.2
562
+ - `max_steps`: 100
563
+ - `warmup_steps`: 150
564
+
565
+ #### All Hyperparameters
566
+ <details><summary>Click to expand</summary>
567
+
568
+ - `overwrite_output_dir`: False
569
+ - `do_predict`: False
570
+ - `eval_strategy`: steps
571
+ - `prediction_loss_only`: True
572
+ - `per_device_train_batch_size`: 8
573
+ - `per_device_eval_batch_size`: 8
574
+ - `per_gpu_train_batch_size`: None
575
+ - `per_gpu_eval_batch_size`: None
576
+ - `gradient_accumulation_steps`: 1
577
+ - `eval_accumulation_steps`: None
578
+ - `torch_empty_cache_steps`: None
579
+ - `learning_rate`: 5e-05
580
+ - `weight_decay`: 0.2
581
+ - `adam_beta1`: 0.9
582
+ - `adam_beta2`: 0.999
583
+ - `adam_epsilon`: 1e-08
584
+ - `max_grad_norm`: 1.0
585
+ - `num_train_epochs`: 3.0
586
+ - `max_steps`: 100
587
+ - `lr_scheduler_type`: linear
588
+ - `lr_scheduler_kwargs`: {}
589
+ - `warmup_ratio`: 0.0
590
+ - `warmup_steps`: 150
591
+ - `log_level`: passive
592
+ - `log_level_replica`: warning
593
+ - `log_on_each_node`: True
594
+ - `logging_nan_inf_filter`: True
595
+ - `save_safetensors`: True
596
+ - `save_on_each_node`: False
597
+ - `save_only_model`: False
598
+ - `restore_callback_states_from_checkpoint`: False
599
+ - `no_cuda`: False
600
+ - `use_cpu`: False
601
+ - `use_mps_device`: False
602
+ - `seed`: 42
603
+ - `data_seed`: None
604
+ - `jit_mode_eval`: False
605
+ - `use_ipex`: False
606
+ - `bf16`: False
607
+ - `fp16`: False
608
+ - `fp16_opt_level`: O1
609
+ - `half_precision_backend`: auto
610
+ - `bf16_full_eval`: False
611
+ - `fp16_full_eval`: False
612
+ - `tf32`: None
613
+ - `local_rank`: 0
614
+ - `ddp_backend`: None
615
+ - `tpu_num_cores`: None
616
+ - `tpu_metrics_debug`: False
617
+ - `debug`: []
618
+ - `dataloader_drop_last`: False
619
+ - `dataloader_num_workers`: 0
620
+ - `dataloader_prefetch_factor`: None
621
+ - `past_index`: -1
622
+ - `disable_tqdm`: False
623
+ - `remove_unused_columns`: True
624
+ - `label_names`: None
625
+ - `load_best_model_at_end`: False
626
+ - `ignore_data_skip`: False
627
+ - `fsdp`: []
628
+ - `fsdp_min_num_params`: 0
629
+ - `fsdp_config`: {'min_num_params': 0, 'xla': False, 'xla_fsdp_v2': False, 'xla_fsdp_grad_ckpt': False}
630
+ - `fsdp_transformer_layer_cls_to_wrap`: None
631
+ - `accelerator_config`: {'split_batches': False, 'dispatch_batches': None, 'even_batches': True, 'use_seedable_sampler': True, 'non_blocking': False, 'gradient_accumulation_kwargs': None}
632
+ - `deepspeed`: None
633
+ - `label_smoothing_factor`: 0.0
634
+ - `optim`: adamw_torch
635
+ - `optim_args`: None
636
+ - `adafactor`: False
637
+ - `group_by_length`: False
638
+ - `length_column_name`: length
639
+ - `ddp_find_unused_parameters`: None
640
+ - `ddp_bucket_cap_mb`: None
641
+ - `ddp_broadcast_buffers`: False
642
+ - `dataloader_pin_memory`: True
643
+ - `dataloader_persistent_workers`: False
644
+ - `skip_memory_metrics`: True
645
+ - `use_legacy_prediction_loop`: False
646
+ - `push_to_hub`: False
647
+ - `resume_from_checkpoint`: None
648
+ - `hub_model_id`: None
649
+ - `hub_strategy`: every_save
650
+ - `hub_private_repo`: False
651
+ - `hub_always_push`: False
652
+ - `gradient_checkpointing`: False
653
+ - `gradient_checkpointing_kwargs`: None
654
+ - `include_inputs_for_metrics`: False
655
+ - `eval_do_concat_batches`: True
656
+ - `fp16_backend`: auto
657
+ - `push_to_hub_model_id`: None
658
+ - `push_to_hub_organization`: None
659
+ - `mp_parameters`:
660
+ - `auto_find_batch_size`: False
661
+ - `full_determinism`: False
662
+ - `torchdynamo`: None
663
+ - `ray_scope`: last
664
+ - `ddp_timeout`: 1800
665
+ - `torch_compile`: False
666
+ - `torch_compile_backend`: None
667
+ - `torch_compile_mode`: None
668
+ - `dispatch_batches`: None
669
+ - `split_batches`: None
670
+ - `include_tokens_per_second`: False
671
+ - `include_num_input_tokens_seen`: False
672
+ - `neftune_noise_alpha`: None
673
+ - `optim_target_modules`: None
674
+ - `batch_eval_metrics`: False
675
+ - `eval_on_start`: False
676
+ - `eval_use_gather_object`: False
677
+ - `batch_sampler`: batch_sampler
678
+ - `multi_dataset_batch_sampler`: proportional
679
+
680
+ </details>
681
+
682
+ ### Training Logs
683
+ | Epoch | Step | loss | spearman_max |
684
+ |:------:|:----:|:------:|:------------:|
685
+ | 0.5263 | 20 | 0.3765 | 0.5421 |
686
+ | 1.0526 | 40 | 0.1518 | 0.5774 |
687
+ | 1.5789 | 60 | 0.0501 | 0.8533 |
688
+ | 2.1053 | 80 | 0.0217 | 0.8900 |
689
+ | 2.6316 | 100 | 0.0168 | 0.9014 |
690
+
691
+
692
+ ### Framework Versions
693
+ - Python: 3.9.10
694
+ - Sentence Transformers: 3.1.0
695
+ - Transformers: 4.44.2
696
+ - PyTorch: 2.4.1+cpu
697
+ - Accelerate: 0.34.2
698
+ - Datasets: 3.0.0
699
+ - Tokenizers: 0.19.1
700
+
701
+ ## Citation
702
+
703
+ ### BibTeX
704
+
705
+ #### Sentence Transformers
706
+ ```bibtex
707
+ @inproceedings{reimers-2019-sentence-bert,
708
+ title = "Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks",
709
+ author = "Reimers, Nils and Gurevych, Iryna",
710
+ booktitle = "Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing",
711
+ month = "11",
712
+ year = "2019",
713
+ publisher = "Association for Computational Linguistics",
714
+ url = "https://arxiv.org/abs/1908.10084",
715
+ }
716
+ ```
717
+
718
+ <!--
719
+ ## Glossary
720
+
721
+ *Clearly define terms in order to be accessible across audiences.*
722
+ -->
723
+
724
+ <!--
725
+ ## Model Card Authors
726
+
727
+ *Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction.*
728
+ -->
729
+
730
+ <!--
731
+ ## Model Card Contact
732
+
733
+ *Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors.*
734
+ -->
config.json ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "distilbert/distilbert-base-uncased-finetuned-sst-2-english",
3
+ "activation": "gelu",
4
+ "architectures": [
5
+ "DistilBertModel"
6
+ ],
7
+ "attention_dropout": 0.1,
8
+ "dim": 768,
9
+ "dropout": 0.1,
10
+ "finetuning_task": "sst-2",
11
+ "hidden_dim": 3072,
12
+ "id2label": {
13
+ "0": "NEGATIVE",
14
+ "1": "POSITIVE"
15
+ },
16
+ "initializer_range": 0.02,
17
+ "label2id": {
18
+ "NEGATIVE": 0,
19
+ "POSITIVE": 1
20
+ },
21
+ "max_position_embeddings": 512,
22
+ "model_type": "distilbert",
23
+ "n_heads": 12,
24
+ "n_layers": 6,
25
+ "output_past": true,
26
+ "pad_token_id": 0,
27
+ "qa_dropout": 0.1,
28
+ "seq_classif_dropout": 0.2,
29
+ "sinusoidal_pos_embds": false,
30
+ "tie_weights_": true,
31
+ "torch_dtype": "float32",
32
+ "transformers_version": "4.44.2",
33
+ "vocab_size": 30522
34
+ }
config_sentence_transformers.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "__version__": {
3
+ "sentence_transformers": "3.1.0",
4
+ "transformers": "4.44.2",
5
+ "pytorch": "2.4.1+cpu"
6
+ },
7
+ "prompts": {},
8
+ "default_prompt_name": null,
9
+ "similarity_fn_name": null
10
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f8384458dfd1d8425d3dc562bb643ae2426261ec0b74b37a3f16b445842dd26c
3
+ size 265462608
modules.json ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ ]
sentence_bert_config.json ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ {
2
+ "max_seq_length": 512,
3
+ "do_lower_case": false
4
+ }
special_tokens_map.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "cls_token": "[CLS]",
3
+ "mask_token": "[MASK]",
4
+ "pad_token": "[PAD]",
5
+ "sep_token": "[SEP]",
6
+ "unk_token": "[UNK]"
7
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "added_tokens_decoder": {
3
+ "0": {
4
+ "content": "[PAD]",
5
+ "lstrip": false,
6
+ "normalized": false,
7
+ "rstrip": false,
8
+ "single_word": false,
9
+ "special": true
10
+ },
11
+ "100": {
12
+ "content": "[UNK]",
13
+ "lstrip": false,
14
+ "normalized": false,
15
+ "rstrip": false,
16
+ "single_word": false,
17
+ "special": true
18
+ },
19
+ "101": {
20
+ "content": "[CLS]",
21
+ "lstrip": false,
22
+ "normalized": false,
23
+ "rstrip": false,
24
+ "single_word": false,
25
+ "special": true
26
+ },
27
+ "102": {
28
+ "content": "[SEP]",
29
+ "lstrip": false,
30
+ "normalized": false,
31
+ "rstrip": false,
32
+ "single_word": false,
33
+ "special": true
34
+ },
35
+ "103": {
36
+ "content": "[MASK]",
37
+ "lstrip": false,
38
+ "normalized": false,
39
+ "rstrip": false,
40
+ "single_word": false,
41
+ "special": true
42
+ }
43
+ },
44
+ "clean_up_tokenization_spaces": true,
45
+ "cls_token": "[CLS]",
46
+ "do_basic_tokenize": true,
47
+ "do_lower_case": true,
48
+ "mask_token": "[MASK]",
49
+ "model_max_length": 512,
50
+ "never_split": null,
51
+ "pad_token": "[PAD]",
52
+ "sep_token": "[SEP]",
53
+ "strip_accents": null,
54
+ "tokenize_chinese_chars": true,
55
+ "tokenizer_class": "DistilBertTokenizer",
56
+ "unk_token": "[UNK]"
57
+ }
vocab.txt ADDED
The diff for this file is too large to render. See raw diff