Browse Source
        
      
      Update
      
        Signed-off-by: Jael Gu <mengjia.gu@zilliz.com>
      
      
        main
      
      
     
    
    
    
	
		
			
				 2 changed files with 
10 additions and 
4 deletions
			 
			
		 
		
			
				- 
					
					
					 
					README.md
				
 
			
				- 
					
						
							
								BIN
							
						
					
					
					 
					result.png
				 
			
		
		
			
			
			
			
			
			
				
				
					
						
							
								
									
	
		
			
				| 
					
					
						
							
						
					
					
				 | 
				@ -30,13 +30,19 @@ to generate a text embedding for the sentence "Hello, world.". | 
			
		
		
	
		
			
				 | 
				 | 
				*Write the pipeline*: | 
				 | 
				 | 
				*Write the pipeline*: | 
			
		
		
	
		
			
				 | 
				 | 
				
 | 
				 | 
				 | 
				
 | 
			
		
		
	
		
			
				 | 
				 | 
				```python | 
				 | 
				 | 
				```python | 
			
		
		
	
		
			
				 | 
				 | 
				import towhee | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				from towhee.dc2 import pipe, ops, DataCollection | 
			
		
		
	
		
			
				 | 
				 | 
				
 | 
				 | 
				 | 
				
 | 
			
		
		
	
		
			
				 | 
				 | 
				towhee.dc(["Hello, world."]) \ | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
				      .text_embedding.longformer(model_name="allenai/longformer-base-4096") \ | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
				      .to_list() | 
				 | 
				 | 
				 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				p = ( | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				    pipe.input('text') | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				        .map('text', 'vec', ops.text_embedding.longformer(model_name="allenai/longformer-base-4096")) | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				        .output('text', 'vec') | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				) | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				
 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				DataCollection(p('Hello, world.')).show() | 
			
		
		
	
		
			
				 | 
				 | 
				``` | 
				 | 
				 | 
				``` | 
			
		
		
	
		
			
				 | 
				 | 
				
 | 
				 | 
				 | 
				
 | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				<img src="./result.png" width="800px"/> | 
			
		
		
	
		
			
				 | 
				 | 
				 | 
				 | 
				 | 
				
 | 
			
		
		
	
		
			
				 | 
				 | 
				<br /> | 
				 | 
				 | 
				<br /> | 
			
		
		
	
		
			
				 | 
				 | 
				
 | 
				 | 
				 | 
				
 | 
			
		
		
	
		
			
				 | 
				 | 
				## Factory Constructor | 
				 | 
				 | 
				## Factory Constructor | 
			
		
		
	
	
		
			
				| 
					
						
							
						
					
					
					
				 | 
				
  | 
			
		
		
	
								
							
						
					 
					
				 
			 
		
			
			
			
			
			
			
				
				
					
					
						
							
								
									
	
		
			
			
				
					
						
						
						
							
							 
							
								
									Width: 
									 | 
									Height: 
									 | 
								
								Size: 5.8 KiB
							 
						
						
					 
				 
				
			 
			
		 
	 |