mirror of
				https://github.com/explosion/spaCy.git
				synced 2025-10-30 23:47:31 +03:00 
			
		
		
		
	custom functions intro
This commit is contained in:
		
							parent
							
								
									7a2e6a96f5
								
							
						
					
					
						commit
						4906a2ae6c
					
				|  | @ -481,9 +481,23 @@ still look good. | |||
| 
 | ||||
| </Accordion> | ||||
| 
 | ||||
| ## Custom model implementations and architectures {#custom-functions} | ||||
| ## Custom Functions {#custom-functions} | ||||
| 
 | ||||
| <!-- TODO: intro, should summarise what spaCy v3 can do and that you can now use fully custom implementations, models defined in PyTorch and TF, etc. etc. --> | ||||
| Registered functions in the training config files can refer to built-in | ||||
| implementations, but you can also plug in fully custom implementations. To do | ||||
| so, you first write your own implementation of a custom architectures, data | ||||
| reader or any other functionality, and then register this function with the | ||||
| correct [registry](/api/top-level#registry). This allows you to plug in models | ||||
| defined in PyTorch or Tensorflow, make custom modifications to the `nlp` object, | ||||
| create custom optimizers or schedules, or write a function that streams in data | ||||
| and preprocesses it on the fly while training. | ||||
| 
 | ||||
| Each custom function can have any numbers of arguments that should be passed | ||||
| into them through the config similar as with the built-in functions. If your | ||||
| function defines **default argument values**, spaCy is able to auto-fill your | ||||
| config when you run [`init fill-config`](/api/cli#init-fill-config). If you want | ||||
| to make sure that a given parameter is always explicitely set in the config, | ||||
| avoid setting a default value for it. | ||||
| 
 | ||||
| ### Training with custom code {#custom-code} | ||||
| 
 | ||||
|  | @ -642,11 +656,7 @@ In your config, you can now reference the schedule in the | |||
| starting with an `@`, it's interpreted as a reference to a function. All other | ||||
| settings in the block will be passed to the function as keyword arguments. Keep | ||||
| in mind that the config shouldn't have any hidden defaults and all arguments on | ||||
| the functions need to be represented in the config. If your function defines | ||||
| **default argument values**, spaCy is able to auto-fill your config when you run | ||||
| [`init fill-config`](/api/cli#init-fill-config). If you want to make sure that a | ||||
| given parameter is always explicitely set in the config, avoid setting a default | ||||
| value for it. | ||||
| the functions need to be represented in the config. | ||||
| 
 | ||||
| ```ini | ||||
| ### config.cfg (excerpt) | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user