KR20180103671A - Electronic apparatus for compressing language model, electronic apparatus for providing recommendation word and operation methods thereof - Google Patents
Electronic apparatus for compressing language model, electronic apparatus for providing recommendation word and operation methods thereof Download PDFInfo
- Publication number
- KR20180103671A KR20180103671A KR1020170147922A KR20170147922A KR20180103671A KR 20180103671 A KR20180103671 A KR 20180103671A KR 1020170147922 A KR1020170147922 A KR 1020170147922A KR 20170147922 A KR20170147922 A KR 20170147922A KR 20180103671 A KR20180103671 A KR 20180103671A
- Authority
- KR
- South Korea
- Prior art keywords
- matrix
- projection
- word
- data
- shared
- Prior art date
Links
- 238000000034 method Methods 0.000 title claims description 60
- 239000011159 matrix material Substances 0.000 claims abstract description 847
- 238000013528 artificial neural network Methods 0.000 claims abstract description 12
- 230000000306 recurrent effect Effects 0.000 claims abstract description 12
- 239000013598 vector Substances 0.000 claims description 131
- 238000012360 testing method Methods 0.000 claims description 15
- 238000013507 mapping Methods 0.000 claims description 12
- 230000001131 transforming effect Effects 0.000 claims description 11
- 238000000354 decomposition reaction Methods 0.000 claims description 7
- 238000012549 training Methods 0.000 claims description 5
- 238000011017 operating method Methods 0.000 claims 2
- 230000015556 catabolic process Effects 0.000 abstract description 8
- 238000006731 degradation reaction Methods 0.000 abstract description 8
- 238000012545 processing Methods 0.000 description 25
- 238000004891 communication Methods 0.000 description 15
- 230000006835 compression Effects 0.000 description 14
- 238000007906 compression Methods 0.000 description 14
- 238000005516 engineering process Methods 0.000 description 11
- 238000013473 artificial intelligence Methods 0.000 description 10
- 238000010586 diagram Methods 0.000 description 9
- 230000008569 process Effects 0.000 description 7
- 230000006870 function Effects 0.000 description 6
- 238000004422 calculation algorithm Methods 0.000 description 5
- 238000013140 knowledge distillation Methods 0.000 description 5
- 238000004364 calculation method Methods 0.000 description 4
- 238000004590 computer program Methods 0.000 description 4
- 238000010801 machine learning Methods 0.000 description 4
- 238000013135 deep learning Methods 0.000 description 3
- 230000010354 integration Effects 0.000 description 3
- 238000009877 rendering Methods 0.000 description 3
- 210000004556 brain Anatomy 0.000 description 2
- 238000006243 chemical reaction Methods 0.000 description 2
- 238000001914 filtration Methods 0.000 description 2
- 238000012986 modification Methods 0.000 description 2
- 230000004048 modification Effects 0.000 description 2
- 238000013139 quantization Methods 0.000 description 2
- 230000003321 amplification Effects 0.000 description 1
- 230000006399 behavior Effects 0.000 description 1
- 230000015572 biosynthetic process Effects 0.000 description 1
- 125000004122 cyclic group Chemical group 0.000 description 1
- 230000003247 decreasing effect Effects 0.000 description 1
- 238000013136 deep learning model Methods 0.000 description 1
- 230000003993 interaction Effects 0.000 description 1
- 230000007774 longterm Effects 0.000 description 1
- 238000007726 management method Methods 0.000 description 1
- 238000003058 natural language processing Methods 0.000 description 1
- 238000003199 nucleic acid amplification method Methods 0.000 description 1
- 238000005457 optimization Methods 0.000 description 1
- 230000004044 response Effects 0.000 description 1
- 238000000060 site-specific infrared dichroism spectroscopy Methods 0.000 description 1
- 238000003786 synthesis reaction Methods 0.000 description 1
- 238000013519 translation Methods 0.000 description 1
- 230000000007 visual effect Effects 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F17/00—Digital computing or data processing equipment or methods, specially adapted for specific functions
- G06F17/10—Complex mathematical operations
- G06F17/16—Matrix or vector computation, e.g. matrix-matrix or matrix-vector multiplication, matrix factorization
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06N—COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06N3/00—Computing arrangements based on biological models
- G06N3/02—Neural networks
- G06N3/08—Learning methods
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/30—Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
- G06F16/33—Querying
- G06F16/3331—Query processing
- G06F16/334—Query execution
- G06F16/3347—Query execution using vector based model
-
- G06F17/3069—
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F3/00—Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
- G06F3/01—Input arrangements or combined input and output arrangements for interaction between user and computer
- G06F3/03—Arrangements for converting the position or the displacement of a member into a coded form
- G06F3/041—Digitisers, e.g. for touch screens or touch pads, characterised by the transducing means
- G06F3/044—Digitisers, e.g. for touch screens or touch pads, characterised by the transducing means by capacitive means
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F40/00—Handling natural language data
- G06F40/20—Natural language analysis
- G06F40/205—Parsing
- G06F40/216—Parsing using statistical methods
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F40/00—Handling natural language data
- G06F40/20—Natural language analysis
- G06F40/274—Converting codes to words; Guess-ahead of partial word inputs
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F40/00—Handling natural language data
- G06F40/20—Natural language analysis
- G06F40/279—Recognition of textual entities
- G06F40/284—Lexical analysis, e.g. tokenisation or collocates
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06N—COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06N3/00—Computing arrangements based on biological models
- G06N3/02—Neural networks
- G06N3/04—Architecture, e.g. interconnection topology
- G06N3/044—Recurrent networks, e.g. Hopfield networks
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06N—COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06N3/00—Computing arrangements based on biological models
- G06N3/02—Neural networks
- G06N3/04—Architecture, e.g. interconnection topology
- G06N3/045—Combinations of networks
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06N—COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06N5/00—Computing arrangements using knowledge-based models
- G06N5/02—Knowledge representation; Symbolic representation
- G06N5/022—Knowledge engineering; Knowledge acquisition
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- Computational Linguistics (AREA)
- Mathematical Physics (AREA)
- Data Mining & Analysis (AREA)
- Health & Medical Sciences (AREA)
- Artificial Intelligence (AREA)
- General Health & Medical Sciences (AREA)
- Computing Systems (AREA)
- Software Systems (AREA)
- Life Sciences & Earth Sciences (AREA)
- Evolutionary Computation (AREA)
- Molecular Biology (AREA)
- Biophysics (AREA)
- Biomedical Technology (AREA)
- Audiology, Speech & Language Pathology (AREA)
- Computational Mathematics (AREA)
- Mathematical Analysis (AREA)
- Mathematical Optimization (AREA)
- Pure & Applied Mathematics (AREA)
- Databases & Information Systems (AREA)
- Algebra (AREA)
- Probability & Statistics with Applications (AREA)
- Human Computer Interaction (AREA)
- Machine Translation (AREA)
Abstract
Description
본 발명은 딥러닝 등의 기계 학습 알고리즘을 활용하여 인간 두뇌의 인지, 판단 등의 기능을 모사하는 인공지능(Artificial Intelligence, AI) 시스템 및 그 응용 중 언어 모델을 압축하기 위한 전자 장치, 추천 워드를 제공하기 위한 전자 장치 및 그 동작 방법들에 대한 것으로, 더욱 상세하게는 RNN(Recurrent Neural Network) 학습(training)된 언어 모델에 기초한 언어 모델을 압축하기 위한 전자 장치, 추천 워드를 제공하기 위한 전자 장치 및 그 동작 방법들에 대한 것이다.The present invention relates to an artificial intelligence (AI) system that simulates functions such as recognition and judgment of a human brain using a machine learning algorithm such as deep learning, an electronic device for compressing a language model among the applications, And more particularly to an electronic device for compressing a language model based on a Recurrent Neural Network (RNN) -treated language model, an electronic device for providing a recommendation word, And methods of operation thereof.
인공지능(Artificial Intelligence, AI) 시스템은 인간 수준의 지능을 구현하는 컴퓨터 시스템이며, 기존 Rule 기반 스마트 시스템과 달리 기계가 스스로 학습하고 판단하며 똑똑해지는 시스템이다. 인공지능 시스템은 사용할수록 인식률이 향상되고 사용자 취향을 보다 정확하게 이해할 수 있게 되어, 기존 Rule 기반 스마트 시스템은 점차 딥러닝 기반 인공지능 시스템으로 대체되고 있다.Artificial intelligence (AI) system is a computer system that implements human-level intelligence. Unlike existing Rule-based smart systems, AI is a system in which machines learn, judge and become smart. Artificial intelligence systems are increasingly recognized and improving their understanding of user preferences as they are used, and existing rule-based smart systems are gradually being replaced by deep-run-based artificial intelligence systems.
인공지능 기술은 기계학습(딥러닝) 및 기계학습을 활용한 요소 기술들로 구성된다.Artificial intelligence technology consists of element technologies that utilize deep learning and machine learning.
기계학습은 입력 데이터들의 특징을 스스로 분류/학습하는 알고리즘 기술이며, 요소기술은 딥러닝 등의 기계학습 알고리즘을 활용하여 인간 두뇌의 인지, 판단 등의 기능을 모사하는 기술로서, 언어적 이해, 시각적 이해, 추론/예측, 지식 표현, 동작 제어 등의 기술 분야로 구성된다.Machine learning is an algorithm technology that classifies / learns the characteristics of input data by itself. Element technology is a technology that simulates functions such as recognition and judgment of human brain using machine learning algorithms such as deep learning. Understanding, reasoning / prediction, knowledge representation, and motion control.
인공지능 기술이 응용되는 다양한 분야는 다음과 같다. 언어적 이해는 인간의 언어/문자를 인식하고 응용/처리하는 기술로서, 자연어 처리, 기계 번역, 대화시스템, 질의 응답, 음성 인식/합성 등을 포함한다. 시각적 이해는 사물을 인간의 시각처럼 인식하여 처리하는 기술로서, 객체 인식, 객체 추적, 영상 검색, 사람 인식, 장면 이해, 공간 이해, 영상 개선 등을 포함한다. 추론 예측은 정보를 판단하여 논리적으로 추론하고 예측하는 기술로서, 지식/확률 기반 추론, 최적화 예측, 선호 기반 계획, 추천 등을 포함한다. 지식 표현은 인간의 경험정보를 지식데이터로 자동화 처리하는 기술로서, 지식 구축(데이터 생성/분류), 지식 관리(데이터 활용) 등을 포함한다. 동작 제어는 차량의 자율 주행, 로봇의 움직임을 제어하는 기술로서, 움직임 제어(항법, 충돌, 주행), 조작 제어(행동 제어) 등을 포함한다.The various fields in which artificial intelligence technology is applied are as follows. Linguistic understanding is a technology for recognizing, applying, and processing human language / characters, including natural language processing, machine translation, dialogue system, query response, speech recognition / synthesis, and the like. Visual understanding is a technology for recognizing and processing objects as human vision, including object recognition, object tracking, image search, human recognition, scene understanding, spatial understanding, and image enhancement. Inference prediction is a technique for judging and logically inferring and predicting information, including knowledge / probability based reasoning, optimization prediction, preference base planning, and recommendation. Knowledge representation is a technology for automating human experience information into knowledge data, including knowledge building (data generation / classification) and knowledge management (data utilization). The motion control is a technique for controlling the autonomous travel of the vehicle and the motion of the robot, and includes motion control (navigation, collision, traveling), operation control (behavior control), and the like.
예를 들어, 인공지능 시스템은 다양한 문장을 학습하고, 학습 결과에 따른 언어 모델(language model)의 생성에 적용될 수 있다. 또한, 생성된 언어 모델에 기초하여 학습과 유사한 과정을 통해 새로운 워드를 제공하거나 문장을 완성할 수도 있다.For example, an artificial intelligence system can be applied to the learning of various sentences and the generation of language models according to learning results. It is also possible to provide a new word or complete a sentence through a process similar to learning based on the generated language model.
이러한 언어 모델은 방대한 문장의 학습에 따라 생성이 가능하며, 특히 언어 모델의 차원이 높아질수록 완성도가 향상될 수 있다. 다만, 언어 모델의 차원이 높아질수록 언어 모델의 데이터량은 기하급수적으로 증가하게 되며, 저장 공간이 부족한 장치 등에서는 사용이 어려운 문제가 있었다. 또는, 저장 공간이 부족한 장치에서 사용할 언어 모델의 생성을 위해 차원을 낮출 경우, 성능이 저하되는 문제가 있었다. 그에 따라, 언어 모델의 성능 저하를 최소화하면서도 데이터량을 감소시킬 수 있는 방법이 필요하게 되었다.This language model can be generated according to the learning of a large number of sentences. In particular, the higher the level of the language model, the higher the completeness. However, as the level of the language model increases, the amount of data of the language model increases exponentially, and it is difficult to use the device in a device lacking storage space. Or, if the dimension is lowered to create a language model to be used in a device with insufficient storage space, there is a problem that performance is degraded. Accordingly, there is a need for a method capable of reducing the amount of data while minimizing degradation of the language model.
본 발명은 상술한 필요성에 따른 것으로, 본 발명의 목적은 RNN(Recurrent Neural Network) 학습(training)된 언어 모델을 성능 저하 없이 압축하는 전자 장치, 압축된 언어 모델에 기초하여 추천 워드를 제공하는 전자 장치 및 그 동작 방법들을 제공함에 있다.It is an object of the present invention to provide an electronic device that compresses a Recurrent Neural Network (RNN) -treated language model without degradation, an electronic device that provides a recommendation word based on a compressed language model, Apparatus and methods of operation thereof.
이상과 같은 목적을 달성하기 위한 본 발명의 일 실시 예에 따른 언어 모델을 압축하기 위한 전자 장치는 복수의 문장(sentence)을 포함하는 기본 데이터로 RNN(Recurrent Neural Network) 학습(training)된 임베딩 행렬(embedding matrix) 및 소프트맥스 행렬(softmax matrix)을 포함하는 언어 모델이 저장된 스토리지 및 상기 임베딩 행렬을 행렬의 크기가 동일한 제1 프로젝션 행렬(projection matrix) 및 공유 행렬의 곱으로 변환하고, 상기 소프트맥스 행렬의 전치 행렬을 행렬의 크기가 동일한 제2 프로젝션 행렬 및 상기 공유 행렬로 변환하며, 상기 제1 프로젝션 행렬, 상기 제2 프로젝션 행렬 및 상기 공유 행렬을 상기 기본 데이터로 상기 RNN 학습하여 상기 제1 프로젝션 행렬, 상기 제2 프로젝션 행렬 및 상기 공유 행렬 각각의 엘리먼트(element)를 업데이트하는 프로세서를 포함한다.In order to achieve the above object, an electronic device for compressing a language model according to an embodiment of the present invention includes an embedding matrix (RNN) trained as basic data including a plurality of sentences, a storage matrix storing a language model including an embedding matrix and a softmax matrix and a storage matrix storing the storage matrix and a matrix of a first projection matrix and a shared matrix having the same matrix size, Transforming the transposed matrix of the matrix into a second projection matrix and a shared matrix having the same matrix size, and performing RNN learning on the first projection matrix, the second projection matrix, and the sharing matrix with the basic data, A processor for updating elements of each of the matrix, the second projection matrix and the shared matrix .
또한, 상기 프로세서는 테스트 모듈에 기초하여 상기 제1 프로젝션 행렬, 상기 제2 프로젝션 행렬 및 상기 공유 행렬에 대한 워드 퍼플렉시티(word perplexity)를 산출하고, 상기 워드 퍼플렉시티가 기설정된 값 이상이면 상기 공유 행렬보다 행렬의 크기(size)가 큰 새로운 공유 행렬을 획득하며, 상기 워드 퍼플렉시티가 상기 기설정된 값 미만이면 상기 공유 행렬보다 행렬의 크기가 작은 새로운 공유 행렬을 획득하고, 상기 획득된 새로운 공유 행렬을 이용하여 상기 제1 프로젝션 행렬, 상기 제2 프로젝션 행렬 및 상기 공유 행렬을 재산출할 수 있다.In addition, the processor may calculate a word perplexity for the first projection matrix, the second projection matrix and the sharing matrix based on the test module, and if the word perparency is greater than or equal to a predetermined value Acquires a new shared matrix having a matrix size larger than the shared matrix, and acquires a new shared matrix having a matrix smaller than the shared matrix if the word-polarized is less than the predetermined value, The first projection matrix, the second projection matrix, and the shared matrix may be reassigned using a new shared matrix.
그리고, 상기 프로세서는 상기 테스트 모듈에 기초하여 상기 임베딩 행렬 및 상기 소프트맥스 행렬에 대한 기준 워드 퍼플렉시티를 산출하고, 상기 기준 워드 퍼플렉시티에 기초하여 상기 기설정된 값을 결정할 수 있다.The processor may calculate a reference wordperformance for the embedded matrix and the soft-max matrix based on the test module, and may determine the preset value based on the reference wordperformance.
또한, 상기 프로세서는 상기 워드 퍼플렉시티가 상기 기설정된 값 미만인 복수의 공유 행렬 중 행렬의 크기가 가장 작은 공유 행렬로 상기 제1 프로젝션 행렬, 상기 제2 프로젝션 행렬 및 상기 공유 행렬을 재산출하고, 재산출된 상기 제1 프로젝션 행렬, 상기 제2 프로젝션 행렬 및 상기 공유 행렬로 압축된 언어 모델을 생성할 수 있다.The processor recalculates the first projection matrix, the second projection matrix, and the shared matrix with a shared matrix having a smallest matrix size among a plurality of shared matrices in which the word power is less than the preset value, The re-computed first projection matrix, the second projection matrix, and the shared matrix.
그리고, 상기 프로세서는 SVD(Singular Value Decomposition)를 이용하여 상기 공유 행렬을 제1 행렬, 제2 행렬 및 제3 행렬로 변환하고, 상기 제1 프로젝션 행렬, 상기 제2 프로젝션 행렬, 상기 제1 행렬, 상기 제2 행렬 및 상기 제3 행렬을 상기 기본 데이터로 상기 RNN 학습하여 상기 제1 프로젝션 행렬, 상기 제2 프로젝션 행렬, 상기 제1 행렬, 상기 제2 행렬 및 상기 제3 행렬 각각의 엘리먼트를 업데이트하며, 상기 엘리먼트가 업데이트된 상기 제1 프로젝션 행렬, 상기 제2 프로젝션 행렬, 상기 제1 행렬, 상기 제2 행렬 및 상기 제3 행렬로 압축된 언어 모델을 생성할 수 있다.The processor may convert the shared matrix into a first matrix, a second matrix and a third matrix using SVD (Singular Value Decomposition), and the first projection matrix, the second projection matrix, the first matrix, Updates the elements of the first projection matrix, the second projection matrix, the first matrix, the second matrix, and the third matrix by RNN learning the second matrix and the third matrix with the basic data , The first projection matrix, the second projection matrix, the first matrix, the second matrix, and the third matrix updated with the updated element.
또한, 상기 프로세서는 상기 복수의 문장 중 하나의 문장에 포함된 제1 워드에 대응되는 제1 벡터를 제1 랜덤 행렬에 기초하여 벡터 공간으로 매핑시킨 제1 데이터를 획득하고, 상기 문장에 포함되고 상기 제1 워드 다음의 제2 워드가 입력되면 상기 제2 워드에 대응되는 제2 벡터를 상기 제1 랜덤 행렬에 기초하여 상기 벡터 공간으로 매핑시킨 제2 데이터를 획득하며, 상기 제1 데이터 및 상기 제2 데이터에 기초하여 제3 데이터를 생성하고, 상기 제3 데이터를 제2 랜덤 행렬에 기초하여 복원 벡터를 획득하며, 상기 복원 벡터 및 상기 제2 워드 다음의 제3 워드에 대응되는 제3 벡터 간의 오차에 기초하여 상기 제1 랜덤 행렬 및 상기 제2 랜덤 행렬의 엘리먼트를 업데이트하여 학습할 수 있다.In addition, the processor obtains first data obtained by mapping a first vector corresponding to a first word included in one of the plurality of sentences into a vector space based on a first random matrix, When a second word following the first word is input, acquiring second data obtained by mapping a second vector corresponding to the second word to the vector space based on the first random matrix, And a third vector corresponding to the third word after the second word, the third vector being generated based on the second data, the third data being obtained based on the second random matrix, And update the elements of the first random matrix and the second random matrix based on the error between the first random matrix and the second random matrix.
그리고, 상기 프로세서는 상기 복수의 문장 중 나머지 문장에 기초하여 상기 제1 랜덤 행렬 및 상기 제2 랜덤 행렬 각각의 엘리먼트를 업데이트하고, 상기 나머지 문장에 기초하여 엘리먼트가 업데이트된 상기 제1 랜덤 행렬 및 상기 제2 랜덤 행렬을 각각 상기 임베딩 행렬 및 상기 소프트맥스 행렬로서 상기 스토리지에 저장할 수 있다.The processor updates the elements of each of the first random matrix and the second random matrix based on the remaining one of the plurality of sentences, and updates the first random matrix and the second random matrix based on the remaining sentence, And store the second random matrix as the embedding matrix and the soft max matrix, respectively, in the storage.
또한, 상기 임베딩 행렬 및 상기 소프트맥스 행렬의 전치 행렬은 크기가 동일할 수 있다.The permutation matrix and the permutation matrix of the soft-max matrix may have the same size.
이상과 같은 목적을 달성하기 위한 본 발명의 일 실시 예에 따른 추천 워드를 제공하기 위한 전자 장치는 임베딩 행렬로 이용되는 제1 프로젝션 행렬, 제1 행렬, 제2 행렬 및 제3 행렬 및 소프트맥스 행렬로 이용되는 제2 프로젝션 행렬, 상기 제1 행렬, 상기 제2 행렬 및 상기 제3 행렬을 포함하는 언어 모델이 저장된 스토리지 및 제1 워드가 입력되면 상기 제1 워드에 대응되는 제1 벡터를 상기 제1 프로젝션 행렬, 상기 제1 행렬, 상기 제2 행렬 및 상기 제3 행렬에 기초하여 벡터 공간으로 매핑시킨 제1 데이터를 획득하고, 상기 제1 데이터를 상기 제2 프로젝션 행렬, 상기 제1 행렬, 상기 제2 행렬 및 상기 제3 행렬에 기초하여 제2 벡터를 획득하며, 상기 제2 벡터에 기초하여 추천 워드를 제공하는 프로세서를 포함한다.According to an aspect of the present invention, there is provided an electronic device for providing a recommended word, including a first projection matrix used as an embedded matrix, a first matrix, a second matrix and a third matrix, A second matrix corresponding to the first word, a second projection matrix used as the first matrix, a storage matrix storing the language matrix including the first matrix, the second matrix and the third matrix, 1 projection matrix, a first matrix mapped to a vector space based on the first matrix, the second matrix and the third matrix, and outputs the first data to the second projection matrix, the first matrix, Obtaining a second vector based on the second matrix and the third matrix, and providing a recommendation word based on the second vector.
또한, 상기 프로세서는 상기 제1 워드가 입력된 후 제2 워드가 입력되면 상기 제2 워드에 대응되는 제3 벡터를 상기 제1 프로젝션 행렬, 상기 제1 행렬, 상기 제2 행렬 및 상기 제3 행렬에 기초하여 상기 벡터 공간으로 매핑시킨 제2 데이터를 획득하고, 상기 제1 데이터 및 상기 제2 데이터에 기초하여 제3 데이터를 생성하며, 상기 제3 데이터를 상기 제2 프로젝션 행렬, 상기 제1 행렬, 상기 제2 행렬 및 상기 제3 행렬에 기초하여 제4 벡터를 획득하며, 상기 제4 벡터에 기초하여 상기 추천 워드를 제공할 수 있다.When the second word is inputted after the first word is inputted, the processor converts the third vector corresponding to the second word into the first projection matrix, the first matrix, the second matrix and the third matrix Acquires second data mapped to the vector space based on the first data and the second data, generates third data based on the first data and the second data, and outputs the third data to the second projection matrix, , Obtain a fourth vector based on the second matrix and the third matrix, and provide the recommendation word based on the fourth vector.
한편, 본 발명의 일 실시 예에 따른 복수의 문장(sentence)을 포함하는 기본 데이터로 RNN(Recurrent Neural Network) 학습(training)된 임베딩 행렬(embedding matrix) 및 소프트맥스 행렬(softmax matrix)을 포함하는 언어 모델이 저장된 전자 장치의 언어 모델을 압축하기 위한 동작 방법은 상기 임베딩 행렬을 행렬의 크기가 동일한 제1 프로젝션 행렬(projection matrix) 및 공유 행렬의 곱으로 변환하고, 상기 소프트맥스 행렬의 전치 행렬을 행렬의 크기가 동일한 제2 프로젝션 행렬 및 상기 공유 행렬로 변환하는 단계 및 상기 제1 프로젝션 행렬, 상기 제2 프로젝션 행렬 및 상기 공유 행렬을 상기 기본 데이터로 상기 RNN 학습하여 상기 제1 프로젝션 행렬, 상기 제2 프로젝션 행렬 및 상기 공유 행렬 각각의 엘리먼트를 업데이트하는 단계를 포함한다.Meanwhile, an embedding matrix and a softmax matrix, which are RNN (Recurrent Neural Network) training, are included in the basic data including a plurality of sentences according to an embodiment of the present invention. An operation method for compressing a language model of an electronic device in which a language model is stored includes converting the embedded matrix into a product of a first projection matrix and a shared matrix having the same matrix size, Transforming the first projection matrix, the second projection matrix, and the sharing matrix into the second projection matrix and the shared matrix having the same matrix size, and the first projection matrix by learning the RNN with the basic data, 2 < / RTI > projection matrix and the elements of each of the shared matrices.
또한, 테스트 모듈에 기초하여 상기 제1 프로젝션 행렬, 상기 제2 프로젝션 행렬 및 상기 공유 행렬에 대한 워드 퍼플렉시티(word perplexity)를 산출하는 단계, 상기 워드 퍼플렉시티가 기설정된 값 이상이면 상기 공유 행렬보다 행렬의 크기(size)가 큰 새로운 공유 행렬을 획득하며, 상기 워드 퍼플렉시티가 상기 기설정된 값 미만이면 상기 공유 행렬보다 행렬의 크기가 작은 새로운 공유 행렬을 획득하는 단계 및 상기 획득된 새로운 공유 행렬을 이용하여 상기 제1 프로젝션 행렬, 상기 제2 프로젝션 행렬 및 상기 공유 행렬을 재산출하는 단계를 더 포함할 수 있다.Calculating a word perplexity for the first projection matrix, the second projection matrix, and the shared matrix based on the test module; if the word perparency is greater than or equal to a predetermined value, Acquiring a new shared matrix having a matrix size larger than a matrix and obtaining a new shared matrix having a smaller matrix size than the shared matrix if the wordperflection is less than the predetermined value; The method may further include restoring the first projection matrix, the second projection matrix, and the shared matrix using a shared matrix.
그리고, 상기 테스트 모듈에 기초하여 상기 임베딩 행렬 및 상기 소프트맥스 행렬에 대한 기준 워드 퍼플렉시티를 산출하는 단계 및 상기 기준 워드 퍼플렉시티에 기초하여 상기 기설정된 값을 결정하는 단계를 더 포함할 수 있다.And calculating a reference wordperformance for the embedding matrix and the soft-max matrix based on the test module, and determining the predetermined value based on the reference wordperformance have.
또한, 상기 재산출하는 단계는 상기 워드 퍼플렉시티가 상기 기설정된 값 미만인 복수의 공유 행렬 중 행렬의 크기가 가장 작은 공유 행렬로 상기 제1 프로젝션 행렬, 상기 제2 프로젝션 행렬 및 상기 공유 행렬을 재산출하고, 재산출된 상기 제1 프로젝션 행렬, 상기 제2 프로젝션 행렬 및 상기 공유 행렬로 압축된 언어 모델을 생성하는 단계를 더 포함할 수 있다.Also, the shipment of the property may be performed by using the first projection matrix, the second projection matrix, and the shared matrix as a shared matrix having the smallest matrix size among the plurality of shared matrices having the word- And generating a compressed language model with the re-computed first projection matrix, the second projection matrix, and the shared matrix.
그리고, SVD(Singular Value Decomposition)를 이용하여 상기 공유 행렬을 제1 행렬, 제2 행렬 및 제3 행렬로 변환하는 단계, 상기 제1 프로젝션 행렬, 상기 제2 프로젝션 행렬, 상기 제1 행렬, 상기 제2 행렬 및 상기 제3 행렬을 상기 기본 데이터로 상기 RNN 학습하여 상기 제1 프로젝션 행렬, 상기 제2 프로젝션 행렬, 상기 제1 행렬, 상기 제2 행렬 및 상기 제3 행렬 각각의 엘리먼트를 업데이트하는 단계 및 상기 엘리먼트가 업데이트된 상기 제1 프로젝션 행렬, 상기 제2 프로젝션 행렬, 상기 제1 행렬, 상기 제2 행렬 및 상기 제3 행렬로 압축된 언어 모델을 생성하는 단계를 더 포함할 수 있다.Transforming the shared matrix into a first matrix, a second matrix and a third matrix using SVD (Singular Value Decomposition); and transforming the first projection matrix, the second projection matrix, the first matrix, Updating the elements of the first projection matrix, the second projection matrix, the first matrix, the second matrix and the third matrix by RNN learning the first matrix, the second matrix and the third matrix with the basic data, And generating a language model compressed with the first projection matrix, the second projection matrix, the first matrix, the second matrix and the third matrix updated with the element.
또한, 상기 복수의 문장 중 하나의 문장에 포함된 제1 워드에 대응되는 제1 벡터를 제1 랜덤 행렬에 기초하여 벡터 공간으로 매핑시킨 제1 데이터를 획득하는 단계, 상기 문장에 포함되고 상기 제1 워드 다음의 제2 워드가 입력되면 상기 제2 워드에 대응되는 제2 벡터를 상기 제1 랜덤 행렬에 기초하여 상기 벡터 공간으로 매핑시킨 제2 데이터를 획득하는 단계, 상기 제1 데이터 및 상기 제2 데이터에 기초하여 제3 데이터를 생성하는 단계, 상기 제3 데이터를 제2 랜덤 행렬에 기초하여 복원 벡터를 획득하는 단계 및 상기 복원 벡터 및 상기 제2 워드 다음의 제3 워드에 대응되는 제3 벡터 간의 오차에 기초하여 상기 제1 랜덤 행렬 및 상기 제2 랜덤 행렬의 엘리먼트를 업데이트하여 학습하는 단계를 더 포함할 수 있다.The method may further include obtaining first data obtained by mapping a first vector corresponding to a first word included in one of the plurality of sentences into a vector space based on a first random matrix, Obtaining second data obtained by mapping a second vector corresponding to the second word to the vector space based on the first random matrix when a second word following one word is input, 2 data; obtaining the third data from the restored vector based on the second random matrix; and generating a third vector based on the restored vector and the third word corresponding to the third word after the second word, And updating the elements of the first random matrix and the second random matrix based on the error between the vectors.
그리고, 상기 복수의 문장 중 나머지 문장에 기초하여 상기 제1 랜덤 행렬 및 상기 제2 랜덤 행렬 각각의 엘리먼트를 업데이트하는 단계 및 상기 나머지 문장에 기초하여 엘리먼트가 업데이트된 상기 제1 랜덤 행렬 및 상기 제2 랜덤 행렬을 각각 상기 임베딩 행렬 및 상기 소프트맥스 행렬로서 저장하는 단계를 더 포함할 수 있다.And updating elements of each of the first random matrix and the second random matrix based on a remaining one of the plurality of sentences, and based on the remaining sentence, determining whether the first random matrix and the second And storing the random matrix as the embedding matrix and the soft-max matrix, respectively.
또한, 상기 임베딩 행렬 및 상기 소프트맥스 행렬의 전치 행렬은 크기가 동일할 수 있다.The permutation matrix and the permutation matrix of the soft-max matrix may have the same size.
한편, 본 발명의 일 실시 예에 따른 임베딩 행렬로 이용되는 제1 프로젝션 행렬, 제1 행렬, 제2 행렬 및 제3 행렬 및 소프트맥스 행렬로 이용되는 제2 프로젝션 행렬, 상기 제1 행렬, 상기 제2 행렬 및 상기 제3 행렬을 포함하는 언어 모델이 저장된 전자 장치의 추천 워드를 제공하기 위한 동작 방법은 제1 워드가 입력되면 상기 제1 워드에 대응되는 제1 벡터를 상기 제1 프로젝션 행렬, 상기 제1 행렬, 상기 제2 행렬 및 상기 제3 행렬에 기초하여 벡터 공간으로 매핑시킨 제1 데이터를 획득하는 단계, 상기 제1 데이터를 상기 제2 프로젝션 행렬, 상기 제1 행렬, 상기 제2 행렬 및 상기 제3 행렬에 기초하여 제2 벡터를 획득하는 단계 및 상기 제2 벡터에 기초하여 추천 워드를 제공하는 단계를 포함한다.Meanwhile, a second projection matrix used as a first projection matrix, a first matrix, a second matrix and a third matrix and a soft-max matrix used as an embedding matrix according to an embodiment of the present invention, the first matrix, 2 matrix and the third matrix, the method comprising the steps of: when a first word is input, converting a first vector corresponding to the first word into the first projection matrix, Acquiring first data mapped to a vector space based on a first matrix, a second matrix and a third matrix, and obtaining the first data as the second projection matrix, the first matrix, Obtaining a second vector based on the third matrix and providing a recommendation word based on the second vector.
또한, 상기 제1 워드가 입력된 후 제2 워드가 입력되면 상기 제2 워드에 대응되는 제3 벡터를 상기 제1 프로젝션 행렬, 상기 제1 행렬, 상기 제2 행렬 및 상기 제3 행렬에 기초하여 상기 벡터 공간으로 매핑시킨 제2 데이터를 획득하는 단계, 상기 제1 데이터 및 상기 제2 데이터에 기초하여 제3 데이터를 생성하는 단계, 상기 제3 데이터를 상기 제2 프로젝션 행렬, 상기 제1 행렬, 상기 제2 행렬 및 상기 제3 행렬에 기초하여 제4 벡터를 획득하는 단계 및 상기 제4 벡터에 기초하여 상기 추천 워드를 제공하는 단계를 더 포함할 수 있다.When a second word is input after the first word is inputted, a third vector corresponding to the second word is calculated based on the first projection matrix, the first matrix, the second matrix and the third matrix Generating second data based on the first data and the second data, generating the third data based on the second projection matrix, the first matrix, Obtaining a fourth vector based on the second matrix and the third matrix, and providing the recommendation word based on the fourth vector.
이상과 같은 본 발명의 다양한 실시 예에 따르면, 전자 장치는 RNN(Recurrent Neural Network) 학습(training)된 언어 모델의 데이터를 압축하며, 저장 공간이 상대적으로 작은 전자 장치가 압축된 언어 모델을 저장하며, 압축된 언어 모델에 기초한 추천 워드를 성능 저하를 최소화하면서 제공할 수 있다.According to various embodiments of the present invention, the electronic device compresses data of a language model of a Recurrent Neural Network (RNN), stores a compressed language model of an electronic device having a relatively small storage space, , The recommendation word based on the compressed language model can be provided with minimal degradation of performance.
도 1a는 본 발명의 일 실시 예에 따른 전자 장치를 설명하기 위한 블록도이다.
도 1b는 전자 장치의 세부 구성의 일 예를 나타내는 블럭도이다.
도 2는 본 발명의 다른 실시 예에 따른 전자 장치를 설명하기 위한 블록도이다.
도 3a 및 도 3b는 종래 기술에 따른 RNN 학습을 설명하기 위한 도면들이다.
도 4는 본 발명의 일 실시 예에 따른 압축 방법을 설명하기 위한 도면이다.
도 5는 본 발명의 일 실시 예에 따른 압축된 언어 모델의 성능 및 압축 효율을 나타내는 도면이다.
도 6은 본 발명의 일 실시 예에 따른 전자 장치의 언어 모델을 압축하기 위한 동작 방법을 설명하기 위한 흐름도이다.
도 7은 본 발명의 일 실시 예에 따른 전자 장치의 추천 워드를 제공하기 위한 동작 방법을 설명하기 위한 흐름도이다.1A is a block diagram illustrating an electronic device according to an embodiment of the present invention.
1B is a block diagram showing an example of a detailed configuration of an electronic device.
2 is a block diagram illustrating an electronic device according to another embodiment of the present invention.
3A and 3B are diagrams for explaining RNN learning according to the prior art.
4 is a view for explaining a compression method according to an embodiment of the present invention.
5 illustrates performance and compression efficiency of a compressed language model according to an embodiment of the present invention.
6 is a flowchart illustrating an operation method for compressing a language model of an electronic device according to an embodiment of the present invention.
7 is a flowchart illustrating an operation method for providing a recommendation word of an electronic device according to an embodiment of the present invention.
이하에서, 첨부된 도면을 이용하여 본 발명의 다양한 실시 예들에 대하여 구체적으로 설명한다.In the following, various embodiments of the present invention will be described in detail with reference to the accompanying drawings.
도 1a는 본 발명의 일 실시 예에 따른 전자 장치(100)를 설명하기 위한 블록도이다. 도 1a에 도시된 바와 같이, 전자 장치(100)는 스토리지(110) 및 프로세서(120)를 포함한다.1A is a block diagram illustrating an
전자 장치(100)는 인공 지능 학습이 가능한 장치일 수 있다. 예를 들어, 전자 장치(100)는 데스크탑 PC, 노트북, 스마트폰, 태블릿 PC, 서버 등일 수 있다. 또는, 전자 장치(100)는 클라우딩 컴퓨팅 환경이 구축된 시스템 자체를 의미할 수도 있다. 다만, 이에 한정되는 것은 아니며, 전자 장치(100)는 인공 지능 학습이 가능한 장치라면 어떤 장치라도 무방하다.The
스토리지(110)는 언어 모델(language model)을 저장할 수 있다. 여기서, 언어 모델은 실제 사용자가 사용하는 언어, 예를 들어 문장, 구 등을 모델링한 데이터일 수 있다. 언어 모델을 이용하면 순차적으로 입력된 워드(word)에 기초하여 입력된 워드의 다음 워드로 가장 적절한 추천 워드를 제공할 수 있다.The
스토리지(110)는 복수의 문장(sentence)을 포함하는 기본 데이터를 저장할 수 있다. 여기서, 기본 데이터는 언어 모델의 생성에 필요한 데이터일 수 있다. 즉, 언어 모델은 기본 데이터에 대한 학습(training)을 통해 생성될 수 있다.The
스토리지(110)는 압축되기 전의 언어 모델을 저장할 수 있다. 또한, 스토리지(110)는 후술할 프로세서(120)에 의해 압축된 언어 모델을 저장할 수 있다.The
스토리지(110)는 복수의 문장을 포함하는 기본 데이터로 RNN(Recurrent Neural Network) 학습된 임베딩 행렬(embedding matrix) 및 소프트맥스 행렬(softmax matrix)을 포함하는 언어 모델을 저장할 수 있다. 여기서, RNN은 순환 신경망을 의미하며, 시계열 데이터와 같이 시간의 흐름에 따라 변화하는 데이터를 학습하기 위한 딥 러닝 모델의 일종이다. RNN 학습의 구체적인 방법은 임베딩 행렬 및 소프트맥스 행렬과 함께 후술한다.The
프로세서(120)는 전자 장치(100)의 동작을 전반적으로 제어한다.
일 실시 예에 따라 프로세서(120)는 디지털 시그널 프로세서(digital signal processor(DSP), 마이크로 프로세서(microprocessor), TCON(Time controller)으로 구현될 수 있다. 다만, 이에 한정되는 것은 아니며, 중앙처리장치(central processing unit(CPU)), MCU(Micro Controller Unit), MPU(micro processing unit), 컨트롤러(controller), 어플리케이션 프로세서(application processor(AP)), 또는 커뮤니케이션 프로세서(communication processor(CP)), ARM 프로세서 중 하나 또는 그 이상을 포함하거나, 해당 용어로 정의될 수 있다. 또한, 프로세서(140)는 프로세싱 알고리즘이 내장된 SoC(System on Chip), LSI(large scale integration)로 구현될 수도 있고, FPGA(Field Programmable gate array) 형태로 구현될 수도 있다.According to one embodiment, the
프로세서(120)는 압축되기 전의 언어 모델을 직접 생성하여 스토리지(110)에 저장할 수 있다. 또는, 프로세서(120)는 외부 장치에 의해 생성된 압축되기 전의 언어 모델을 수신하여 스토리지(110)에 저장할 수도 있다. 이하에서는 설명의 편의를 위해 임베딩 행렬 및 소프트맥스 행렬과 함께 RNN 학습을 통한 언어 모델을 직접 생성하는 방법을 설명하고, 이후 언어 모델의 압축 방법을 설명한다.The
프로세서(120)는 스토리지(110)에 저장된 복수의 문장 중 하나의 문장에 포함된 제1 워드에 대응되는 제1 벡터를 제1 랜덤 행렬에 기초하여 벡터 공간으로 매핑시킨 제1 데이터를 획득할 수 있다. 예를 들어, 복수의 문장 중 하나의 문장은 "I am a boy."이고, 제1 워드는 "I"일 수 있다.The
워드에 대응되는 벡터는 1 × m의 크기를 갖는 벡터일 수 있고, 여기서 m은 기본 데이터에 포함된 워드의 종류에 따라 결정될 수 있다. 예를 들어, 기본 데이터에는 서로 상이한 워드가 15000개라고 하면, 워드에 대응되는 벡터는 1 × 15000의 크기를 갖는 벡터일 수 있다. 그리고, 벡터의 15000개의 열 중 하나만이 값이 1이고, 나머지는 0이며, 값이 1인 열의 위치에 기초하여 워드가 결정될 수 있다. 예를 들어, 15000개의 열 중 첫 번째 열의 값이 1이면 "I"를 나타내고, 15000개의 열 중 두 번째 열의 값이 1이면 "you"를 나타낼 수 있다. 이러한 방식으로 프로세서(120)는 제1 워드에 대응되는 제1 벡터를 획득할 수 있다.The vector corresponding to the word may be a vector having a size of 1 x m, where m may be determined according to the kind of word included in the basic data. For example, if the basic data includes 15,000 different words, the vector corresponding to the word may be a vector having a size of 1x15000. Then, a word can be determined based on the position of a column having a value of 1 and a value of 1, and only one of 15000 columns of the vector is 1 and the remainder is 0. For example, if the value of the first column among the 15,000 columns is 1, it represents "I", and if the value of the second column of 15000 columns is 1, "you" can be represented. In this manner, the
제1 랜덤 행렬은 m × n의 크기의 랜덤한 엘리먼트를 갖는 행렬이며, 제1 벡터를 n차원의 벡터 공간으로 매핑하기 위한 행렬일 수 있다. 즉, 프로세서(120)는 제1 벡터를 제1 랜덤 행렬과 곱하여 n차원의 벡터 공간으로 매핑된 제1 데이터를 획득할 수 있다.The first random matrix is a matrix having random elements of size mxn, and may be a matrix for mapping the first vector to an n-dimensional vector space. That is, the
그리고, 프로세서(120)는 동일한 문장에 포함되고 제1 워드 다음의 제2 워드가 입력되면 제2 워드에 대응되는 제2 벡터를 제1 랜덤 행렬에 기초하여 벡터 공간으로 매핑시킨 제2 데이터를 획득할 수 있다. 상술한 예에서, 프로세서(120)는 제2 워드인 "am"에 대응되는 제2 벡터를 제1 랜덤 행렬과 곱하여 n차원의 벡터 공간으로 매핑된 제2 데이터를 획득할 수 있다.When the second word after the first word is input, the
프로세서(120)는 제1 데이터 및 제2 데이터에 기초하여 제3 데이터를 생성할 수 있다. 예를 들어, 프로세서(120)는 LSTM(Long-Short term Memory) 방식에 기초하여 제1 데이터 및 제2 데이터로부터 제3 데이터를 생성할 수 있다. LSTM 방식은 종래 기술이므로 구체적인 설명은 생략한다. 또는, 프로세서(120)는 제1 데이터 및 제2 데이터를 가중합하여 제3 데이터를 생성할 수도 있다.The
프로세서(120)는 제3 데이터를 제2 랜덤 행렬에 기초하여 복원 벡터를 획득할 수 있다. 여기서, 제2 랜덤 행렬은 n × m의 크기의 랜덤한 엘리먼트를 갖는 행렬이며, n차원으로 매핑된 데이터를 벡터로 복원하기 위한 행렬일 수 있다. 즉, 제1 랜덤 행렬 및 제2 랜덤 행렬의 전치 행렬(transposed matrix)은 크기가 동일할 수 있다.The
복원 벡터는 1 × m의 크기를 갖는 벡터일 수 있으나, 각 열의 값은 0에서 1사이의 값을 가지며, 모든 열의 값을 더하면 1이 될 수 있다.The restoration vector may be a vector having a size of 1 x m, but each column value has a value between 0 and 1, and may be 1 when all column values are added.
프로세서(120)는 복원 벡터 및 제2 워드 다음의 제3 워드에 대응되는 제3 벡터 간의 오차에 기초하여 제1 랜덤 행렬 및 제2 랜덤 행렬의 엘리먼트를 업데이트하여 학습할 수 있다. 상술한 예에서 제3 워드는 "a"이며, 복원 벡터가 제3 워드인 "a"에 대응되는 제3 벡터처럼 복원될 수 있도록 프로세서(120)는 제1 랜덤 행렬 및 제2 랜덤 행렬의 엘리먼트를 업데이트할 수 있다.The
프로세서(120)는 이러한 과정을 워드 단위로 수행할 수 있다. 예를 들어, 프로세서(120)는 "I am a"까지의 워드를 입력받고, 각각을 n차원으로 매핑하여 가중합한 데이터를 다시 복원하여 복원 벡터를 획득하고, 복원 벡터 및 "boy"에 대응되는 제4 벡터 간의 오차에 기초하여 제1 랜덤 행렬 및 제2 랜덤 행렬의 엘리먼트를 업데이트하여 학습할 수 있다. 즉, 프로세서(120)는 두 개의 워드 뿐만 아니라 하나의 문장 내에 포함된 더 많은 개수의 워드에 기초하여 학습할 수도 있다. 또한, 프로세서(120)는 하나의 워드에 기초하여 학습할 수도 있다.
프로세서(120)는 이상과 같은 방법으로 하나의 문장 내에서 학습을 완료하고, 새로운 문장을 학습할 수 있다. 이때, 프로세서(120)는 학습이 완료된 이전 문장은 더 이상 고려하지 않을 수 있다. 즉, 프로세서(120)는 문장 단위로 학습하며, 하나의 문장 내의 워드 간의 관계는 다양한 방법을 통해 학습할 수 있다.The
프로세서(120)는 복수의 문장 중 나머지 문장에 기초하여 제1 랜덤 행렬 및 제2 랜덤 행렬 각각의 엘리먼트를 업데이트할 수 있다. 즉, 프로세서(120)는 하나의 문장에 대한 학습이 완료되면, 기본 데이터에 포함된 다른 문장으로 학습을 수행하며, 이러한 과정을 모든 문장에 대하여 수행할 수 있다.
프로세서(120)는 나머지 문장에 기초하여 엘리먼트가 업데이트된 제1 랜덤 행렬 및 제2 랜덤 행렬을 각각 임베딩 행렬 및 소프트맥스 행렬로서 스토리지(110)에 저장할 수 있다. 즉, 기본 데이터에 포함된 모든 문장에 대하여 학습이 완료되면, 제1 랜덤 행렬 및 제2 랜덤 행렬은 각각 임베딩 행렬 및 소프트맥스 행렬로서 스토리지(110)에 저장될 수 있다.The
여기서, 임베딩 행렬 및 소프트맥스 행렬의 전치 행렬은 크기가 동일할 수 있다. 그리고, 임베딩 행렬 및 소프트맥스 행렬의 전치 행렬은 대응되는 엘리먼트가 서로 다를 수 있다. 그에 따라, 하나의 워드가 입력되더라도 추천되는 워드는 달라질 수 있다.Here, the transpose matrix of the embedding matrix and the soft max matrix may have the same size. The transposed matrix of the embedding matrix and the soft-max matrix may have different corresponding elements. Accordingly, even if one word is inputted, the recommended word may be different.
한편, 임베딩 행렬 및 소프트맥스 행렬은 워드 추천을 위한 언어 모델로서 이용될 수 있다. 예를 들어, 사용자가 "I"라는 워드를 입력하면, 프로세서(120)는 "I"에 대응되는 제1 벡터를 임베딩 행렬에 기초하여 벡터 공간으로 매핑시킨 제1 데이터를 획득하고, 제1 데이터를 소프트맥스 행렬에 기초하여 제1 복원 벡터를 생성하며, 제1 복원 벡터에 기초하여 추천 워드를 제공할 수 있다.Meanwhile, the embedding matrix and the soft max matrix can be used as a language model for word recommendation. For example, when the user inputs a word "I ", the
구체적으로, 프로세서(120)는 복원 벡터의 엘리먼트의 값 중 가장 큰 값이 위치한 열에 대응되는 워드를 제1 추천 워드로 제공하고, 복원 벡터의 엘리먼트의 값 중 두 번째로 큰 값이 위치한 열에 대응되는 워드를 제2 추천 워드로 제공할 수 있다. 예를 들어, 프로세서(120)는 제1 추천 워드로 "am"을 제공하고, 제2 추천 워드로 "was"를 추천할 수 있다.Specifically, the
이후, 사용자가 "am", "a"라는 워드를 순차적으로 입력하면, 프로세서(120)는 "am"에 대응되는 제2 벡터 및 "a"에 대응되는 제3 벡터 각각을 임베딩 행렬에 기초하여 벡터 공간으로 매핑시킨 제2 데이터 및 제3 데이터를 획득하고, 제1 데이터, 제2 데이터 및 제3 데이터를 가중합하여 제4 데이터를 생성할 수 있다.Thereafter, when the user sequentially inputs the words "am " and" a ", the
그리고, 프로세서(120)는 제4 데이터를 소프트맥스 행렬에 기초하여 제2 복원 벡터를 생성하며, 제2 복원 벡터에 기초하여 추천 워드를 제공할 수 있다.The
구체적으로, 프로세서(120)는 제2 복원 벡터의 엘리먼트의 값 중 가장 큰 값이 위치한 열에 대응되는 워드를 제1 추천 워드로 제공하고, 제2 복원 벡터의 엘리먼트의 값 중 두 번째로 큰 값이 위치한 열에 대응되는 워드를 제2 추천 워드로 제공할 수 있다. 예를 들어, 프로세서(120)는 제1 추천 워드로 "boy"를 제공하고, 제2 추천 워드로 "girl"을 추천할 수 있다.Specifically, the
이상과 같이 프로세서(120)는 기본 데이터에 대한 RNN 학습을 수행하고, 임베딩 행렬 및 소프트맥스 행렬을 획득할 수 있으며, 획득한 임베딩 행렬 및 소프트맥스 행렬을 포함하는 언어 모델을 생성할 수 있다. 그리고, 언어 모델이 생성되면, 프로세서(120)는 언어 모델에 기초하여 추천 워드를 제공할 수 있다.As described above, the
다만, 임베딩 행렬 및 소프트맥스 행렬은 데이터 크기가 매우 클 수 있다. 예를 들어, 기본 데이터에서 서로 상이한 워드가 15000개이며, 600 차원의 벡터 공간을 이용하는 경우, 15000 × 600의 크기를 갖는 임베딩 행렬 및 600 × 15000의 크기를 갖는 소프트맥스 행렬이 생성될 수 있다. 이 경우, 총 1800만 개의 엘리먼트가 저장될 필요가 있으며, 상당한 저장 공간이 필요하게 된다. 반면, 차원 수를 줄이면 저장되어야 하는 엘리먼트의 개수가 줄어들 수 있으나, 학습 능력이 떨어져 워드 추천 시의 성능이 저하될 수 있다.However, the embedding matrix and the soft max matrix may have a very large data size. For example, when 15000 words are different from each other in the basic data and a vector space of 600 dimensions is used, an embedding matrix having a size of 15000 x 600 and a soft max matrix having a size of 600 x 15000 can be generated. In this case, a total of 18 million elements need to be stored, and a considerable storage space is required. On the other hand, reducing the number of dimensions may reduce the number of elements to be stored, but may deteriorate the performance of word recommendation because of the lack of learning ability.
그에 따라, 이하에서는 성능 저하를 최소화하면서 언어 모델을 압축하는 방법에 대하여 설명한다.Accordingly, a method of compressing a language model while minimizing performance degradation will be described below.
먼저, 프로세서(120)는 스토리지(110)에 저장된 임베딩 행렬을 행렬의 크기가 동일한 제1 프로젝션 행렬(projection matrix) 및 공유 행렬의 곱으로 변환하고, 스토리지(110)에 저장된 소프트맥스 행렬의 전치 행렬을 행렬의 크기가 동일한 제2 프로젝션 행렬 및 공유 행렬로 변환할 수 있다.First, the
예를 들어, 임베딩 행렬이 m × n의 크기를 갖는 행렬인 경우, 프로세서(120)는 임베딩 행렬을 m × l의 크기를 갖는 제1 프로젝션 행렬 및 l × n의 크기를 갖는 공유 행렬로 변환할 수 있다. 여기서, 제1 프로젝션 행렬 및 공유 행렬 각각의 엘리먼트는 랜덤하게 정해질 수 있으며, 임베딩 행렬의 엘리먼트와는 무관할 수 있다.For example, if the embedding matrix is a matrix having a size of mxn, the
또한, 소프트맥스 행렬이 n × m의 크기를 갖는 행렬인 경우, 프로세서(120)는 임베딩 행렬을 m × l의 크기를 갖는 제2 프로젝션 행렬 및 l × n의 크기를 갖는 공유 행렬로 변환할 수 있다. 여기서, 제2 프로젝션 행렬 및 공유 행렬 각각의 엘리먼트는 랜덤하게 정해질 수 있으며, 소프트맥스 행렬의 엘리먼트와는 무관할 수 있다.In addition, when the soft-max matrix is a matrix having a size of n x m, the
좀더 구체적인 예를 들어, 15000 × 600의 크기를 갖는 임베딩 행렬 및 600 × 15000의 크기를 갖는 소프트맥스 행렬을 가정하면, 프로세서(120)는 15000 × 100의 크기를 갖는 제1 프로젝션 행렬, 15000 × 100의 크기를 갖는 제2 프로젝션 행렬 및 100 × 600의 크기를 갖는 공유 행렬을 생성할 수 있다. 이 경우, 임베딩 행렬 및 소프트맥스 행렬의 총 1800만 개의 엘리먼트가 제1 프로젝션 행렬, 제2 프로젝션 행렬 및 공유 행렬의 총 306만 개의 엘리먼트로 감소하게 된다. 즉, l이 작을수록 압축 효율이 향상된다.For example, assuming an embedding matrix having a size of 15000 x 600 and a soft max matrix having a size of 600 x 15000, the
이후, 프로세서(120)는 제1 프로젝션 행렬, 제2 프로젝션 행렬 및 공유 행렬을 기본 데이터로 RNN 학습하여 제1 프로젝션 행렬, 제2 프로젝션 행렬 및 공유 행렬 각각의 엘리먼트를 업데이트할 수 있다. 업데이트 방법은 상술한 임베딩 행렬 및 소프트맥스 행렬을 생성하는 방법과 동일하다.The
즉, 프로세서(120)는 제1 프로젝션 행렬 및 공유 행렬을 곱하여 제1 랜덤 행렬로서 이용하고, 제2 프로젝션 행렬 및 공유 행렬을 곱하고 이의 전치 행렬을 제2 랜덤 행렬로서 이용하며, 기본 데이터에 포함된 모든 문장에 대하여 학습을 수행하여 제1 프로젝션 행렬, 제2 프로젝션 행렬 및 공유 행렬의 엘리먼트를 업데이트할 수 있다.That is, the
이때, 공유 행렬의 크기가 작으면(l이 작으면) 언어 모델의 성능이 저하될 수 있으며, 공유 행렬의 크기가 크면 압축 효율이 떨어지는 문제가 있다. 즉, 언어 모델의 성능을 유지하며 압축 효율을 향상시키기 위해 최적 크기의 공유 행렬을 획득할 필요가 있다. 이하에서는 워드 퍼플렉시티(word perplexity)를 산출하여 최적 크기의 공유 행렬을 획득하는 방법에 대하여 설명한다. 여기서, 퍼플렉시티는 확률 분포 또는 확률 모델이 표본을 얼마나 잘 예측하는지를 나타내는 척도로서, 확률 모델을 비교하는 데 사용될 수 있으며, 낮을수록 양호함을 나타낸다.At this time, if the size of the shared matrix is small (if l is small), the performance of the language model may deteriorate, and if the size of the shared matrix is large, the compression efficiency is low. That is, it is necessary to acquire an optimal size shared matrix to maintain the performance of the language model and improve compression efficiency. Hereinafter, a method of calculating a word perplexity to obtain an optimal size shared matrix will be described. Here, the perplexity is a measure of how well a probability distribution or probability model predicts a sample, which can be used to compare the probability model, and the lower the better, the better.
프로세서(120)는 테스트 모듈에 기초하여 제1 프로젝션 행렬, 제2 프로젝션 행렬 및 공유 행렬에 대한 워드 퍼플렉시티를 산출할 수 있다. 여기서, 테스트 모듈은 언어 모델을 테스트하기 위한 모듈이며, 종류에 있어서 특별한 제한은 없다.The
프로세서(120)는 워드 퍼플렉시티가 기설정된 값 이상이면 공유 행렬보다 행렬의 크기(size)가 큰 새로운 공유 행렬을 획득하며, 워드 퍼플렉시티가 기설정된 값 미만이면 공유 행렬보다 행렬의 크기가 작은 새로운 공유 행렬을 획득하고, 획득된 새로운 공유 행렬을 이용하여 제1 프로젝션 행렬, 제2 프로젝션 행렬 및 공유 행렬을 재산출할 수 있다. 여기서, 제1 프로젝션 행렬, 제2 프로젝션 행렬 및 공유 행렬의 재산출은 학습을 통해 엘리먼트를 업데이트하는 것을 의미한다.The
프로세서(120)는 상술한 예에서 100 × 600의 크기를 갖는 공유 행렬에 의한 워드 퍼플렉시티가 기설정된 값 이상이면 110 × 600의 크기를 갖는 공유 행렬을 획득하고, 워드 퍼플렉시티가 기설정된 값 미만이면 90 × 600의 크기를 갖는 공유 행렬을 획득할 수 있다. 여기서, l의 값을 110 또는 90으로 설명한 것은 일 실시 예에 불과하고, 얼마든지 다른 값으로 설정될 수 있다.The
한편, 프로세서(120)는 테스트 모듈에 기초하여 임베딩 행렬 및 소프트맥스 행렬에 대한 기준 워드 퍼플렉시티를 산출하고, 기준 워드 퍼플렉시티에 기초하여 기설정된 값을 결정할 수 있다.On the other hand, the
예를 들어, 프로세서(120)는 동일한 테스트 모듈에 기초하여 임베딩 행렬 및 소프트맥스 행렬에 대한 기준 워드 퍼플렉시티를 산출하고, 기준 워드 퍼플렉시티 자체를 기설정된 값으로 결정할 수도 있다.For example, the
여기서, 임베딩 행렬 및 소프트맥스 행렬을 이용하는 언어 모델은 설정된 차원에서 최적화된 모델일 수 있다. 이에 대해, 동일한 차원일지라도 임베딩 행렬 및 소프트맥스 행렬의 랭크(rank)보다 l의 값이 작은 공유 행렬을 이용하는 언어 모델은 임베딩 행렬 및 소프트맥스 행렬을 이용하는 언어 모델보다 성능이 저하될 수 있다. 즉, 공유 행렬의 l의 값이 임베딩 행렬 및 소프트맥스 행렬의 랭크보다 무조건 커야 하는 것은 아니나, 너무 작을 경우 최적화된 모델과는 동떨어진 모델이 생성될 가능성이 높다. 이를 보완하기 위해 프로세서(120)는 복수의 공유 행렬에 대하여 학습을 수행할 수 있다.Here, the language model using the embedding matrix and the soft max matrix may be an optimized model in the set dimension. On the other hand, even though the same dimension is used, a language model using a shared matrix having a value smaller by one than the rank of the embedding matrix and the soft-max matrix may be degraded in performance than a language model using an embedding matrix and a soft-max matrix. That is, although the value of l in the shared matrix is not necessarily larger than the rank of the embedding matrix and the soft-max matrix, if the matrix is too small, a model that is far away from the optimized model is likely to be generated. In order to compensate for this, the
즉, 프로세서(120)는 새로운 공유 행렬 및 제1 프로젝션 행렬, 제2 프로젝션 행렬의 엘리먼트를 업데이트한 후, 다시 워드 퍼플렉시티를 산출할 수 있다. 구체적으로, 프로세서(120)는 복수의 공유 행렬 및 각각에 대응되는 제1 프로젝션 행렬, 제2 프로젝션 행렬의 엘리먼트를 업데이트한 후, 각각에 대응되는 워드 퍼플렉시티를 산출할 수 있다.That is, the
프로세서(120)는 워드 퍼플렉시티가 기설정된 값 미만인 복수의 공유 행렬 중 행렬의 크기가 가장 작은 공유 행렬로 제1 프로젝션 행렬, 제2 프로젝션 행렬 및 공유 행렬을 재산출하고, 재산출된 제1 프로젝션 행렬, 제2 프로젝션 행렬 및 공유 행렬로 압축된 언어 모델을 생성할 수 있다.The
이상과 같이 프로세서(120)는 임베딩 행렬 및 소프트맥스 행렬을 포함하는 언어 모델을 제1 프로젝션 행렬, 제2 프로젝션 행렬 및 공유 행렬을 포함하는 언어 모델로 변경함으로써 데이터를 압축할 수 있다. 특히, 임베딩 행렬 및 소프트맥스 행렬을 포함하는 언어 모델과 제1 프로젝션 행렬, 제2 프로젝션 행렬 및 공유 행렬을 포함하는 언어 모델은 차원이 동일하며, 공유 행렬의 크기를 적절히 설정해줌에 따라 압축 효율은 향상시키면서도 성능 저하를 최소화할 수 있다.As described above, the
한편, 프로세서(120)는 SVD(Singular Value Decomposition)를 이용하여 공유 행렬을 제1 행렬, 제2 행렬 및 제3 행렬로 변환할 수 있다. 예를 들어, 프로세서(120)는 l × n의 크기를 갖는 공유 행렬을 l × l의 크기를 갖는 제1 행렬, l × r의 크기를 갖는 제2 행렬 및 r × l의 크기를 갖는 제3 행렬로 변환할 수 있다.Meanwhile, the
좀더 구체적인 예를 들어, 프로세서(120)는 100 × 600의 크기를 갖는 공유 행렬을 100 × 100의 크기를 갖는 제1 행렬, 100 × 20의 크기를 갖는 제2 행렬 및 20 × 600의 크기를 갖는 제3 행렬로 변환할 수 있다. 이 경우, 공유 행렬의 총 6만 개의 엘리먼트가 제1 행렬, 제2 행렬 및 제3 행렬의 총 2.4만 개의 엘리먼트로 감소하게 된다. 즉, 공유 행렬을 한번 더 분해하여 압축 효율을 향상시킬 수 있다.For example, the
여기서, SVD는 특이값 분해를 의미하며, 일반적으로 알려진 기술이므로 구체적인 설명은 생략한다. 그리고, 제1 행렬, 제2 행렬 및 제3 행렬의 엘리먼트는 공유 행렬과는 무관할 수 있다.Here, SVD means singular value decomposition and is a generally known technology, so a detailed description thereof will be omitted. The elements of the first matrix, the second matrix and the third matrix may be independent of the shared matrix.
프로세서(120)는 제1 프로젝션 행렬, 제2 프로젝션 행렬, 제1 행렬, 제2 행렬 및 제3 행렬을 기본 데이터로 RNN 학습하여 제1 프로젝션 행렬, 제2 프로젝션 행렬, 제1 행렬, 제2 행렬 및 제3 행렬 각각의 엘리먼트를 업데이트하며, 엘리먼트가 업데이트된 제1 프로젝션 행렬, 제2 프로젝션 행렬, 제1 행렬, 제2 행렬 및 제3 행렬로 압축된 언어 모델을 생성할 수 있다. 학습을 통해 엘리먼트를 업데이트하는 방법은 상술하였으므로, 구체적인 설명은 생략한다.The
도 1b는 전자 장치(100)의 세부 구성의 일 예를 나타내는 블럭도이다. 도 1b에 따르면, 전자 장치(100)는 스토리지(110), 프로세서(120), 통신부(130), 사용자 인터페이스부(140), 디스플레이(150), 오디오 처리부(160), 비디오 처리부(170)를 포함한다. 도 1b에 도시된 구성요소들 중 도 1a에 도시된 구성요소와 중복되는 부분에 대해서는 자세한 설명을 생략하도록 한다.1B is a block diagram showing an example of a detailed configuration of the
프로세서(120)는 스토리지(110)에 저장된 각종 프로그램을 이용하여 전자 장치(100)의 동작을 전반적으로 제어한다.The
구체적으로, 프로세서(120)는 RAM(121), ROM(122), 메인 CPU(123), 그래픽 처리부(124), 제1 내지 n 인터페이스(125-1 ~ 125-n), 버스(126)를 포함한다.Specifically, the
RAM(121), ROM(122), 메인 CPU(123), 그래픽 처리부(124), 제1 내지 n 인터페이스(125-1 ~ 125-n) 등은 버스(126)를 통해 서로 연결될 수 있다. The
제1 내지 n 인터페이스(125-1 내지 125-n)는 상술한 각종 구성요소들과 연결된다. 인터페이스들 중 하나는 네트워크를 통해 외부 장치와 연결되는 네트워크 인터페이스가 될 수도 있다.The first to n-th interfaces 125-1 to 125-n are connected to the various components described above. One of the interfaces may be a network interface connected to an external device via a network.
메인 CPU(123)는 스토리지(110)에 액세스하여, 스토리지(110)에 저장된 O/S를 이용하여 부팅을 수행한다. 그리고, 스토리지(110)에 저장된 각종 프로그램 등을 이용하여 다양한 동작을 수행한다.The
ROM(122)에는 시스템 부팅을 위한 명령어 세트 등이 저장된다. 턴온 명령이 입력되어 전원이 공급되면, 메인 CPU(123)는 ROM(122)에 저장된 명령어에 따라 스토리지(110)에 저장된 O/S를 RAM(121)에 복사하고, O/S를 실행시켜 시스템을 부팅시킨다. 부팅이 완료되면, 메인 CPU(123)는 스토리지(110)에 저장된 각종 어플리케이션 프로그램을 RAM(121)에 복사하고, RAM(121)에 복사된 어플리케이션 프로그램을 실행시켜 각종 동작을 수행한다.The
그래픽 처리부(124)는 연산부(미도시) 및 렌더링부(미도시)를 이용하여 아이콘, 이미지, 텍스트 등과 같은 다양한 객체를 포함하는 화면을 생성한다. 연산부(미도시)는 수신된 제어 명령에 기초하여 화면의 레이아웃에 따라 각 객체들이 표시될 좌표값, 형태, 크기, 컬러 등과 같은 속성값을 연산한다. 렌더링부(미도시)는 연산부(미도시)에서 연산한 속성값에 기초하여 객체를 포함하는 다양한 레이아웃의 화면을 생성한다. 렌더링부(미도시)에서 생성된 화면은 디스플레이(150)의 디스플레이 영역 내에 표시된다.The
한편, 상술한 프로세서(120)의 동작은 스토리지(110)에 저장된 프로그램에 의해 이루어질 수 있다.The operation of the
스토리지(110)는 전자 장치(100)를 구동시키기 위한 O/S(Operating System) 소프트웨어 모듈, 임베딩 행렬 및 소프트맥스 행렬을 포함하는 언어 모델, 언어 모델을 압축하기 위한 압축 모듈 및 RNN 학습 모듈 등과 같이 다양한 데이터를 저장한다.The
통신부(130)는 다양한 유형의 통신방식에 따라 다양한 유형의 외부 장치와 통신을 수행하는 구성이다. 통신부(130)는 와이파이 칩(131), 블루투스 칩(132), 무선 통신 칩(133), NFC 칩(134) 등을 포함한다. 프로세서(120)는 통신부(130)를 이용하여 각종 외부 장치와 통신을 수행한다.The
와이파이 칩(131), 블루투스 칩(132)은 각각 WiFi 방식, 블루투스 방식으로 통신을 수행한다. 와이파이 칩(131)이나 블루투스 칩(132)을 이용하는 경우에는 SSID 및 세션 키 등과 같은 각종 연결 정보를 먼저 송수신하여, 이를 이용하여 통신 연결한 후 각종 정보들을 송수신할 수 있다. 무선 통신 칩(133)은 IEEE, 지그비(zigbee), 3G(3rd Generation), 3GPP(3rd Generation Partnership Project), LTE(Long Term Evoloution) 등과 같은 다양한 통신 규격에 따라 통신을 수행하는 칩을 의미한다. NFC 칩(134)은 135kHz, 13.56MHz, 433MHz, 860~960MHz, 2.45GHz 등과 같은 다양한 RF-ID 주파수 대역들 중에서 13.56MHz 대역을 사용하는 NFC(Near Field Communication) 방식으로 동작하는 칩을 의미한다.The Wi-
프로세서(130)는 통신부(130)를 통해 외부 장치로부터 임베딩 행렬 및 소프트맥스 행렬을 포함하는 언어 모델을 수신할 수 있다.The
사용자 인터페이스부(140)는 다양한 사용자 인터랙션(interaction)을 수신한다. 여기서, 사용자 인터페이스부(140)는 전자 장치(100)의 구현 예에 따라 다양한 형태로 구현 가능하다. 예를 들어, 사용자 인터페이스부(140)는 전자 장치(100)에 구비된 버튼, 사용자 음성을 수신하는 마이크, 사용자 모션을 감지하는 카메라 등일 수 있다. 또는, 전자 장치(100)가 터치 기반의 전자 장치로 구현되는 경우 사용자 인터페이스부(140)는 터치패드와 상호 레이어 구조를 이루는 터치 스크린 형태로 구현될 수도 있다. 이 경우, 사용자 인터페이스부(140)는 상술한 디스플레이(150)로 사용될 수 있게 된다.The
오디오 처리부(160)는 오디오 데이터에 대한 처리를 수행하는 구성요소이다. 오디오 처리부(160)에서는 오디오 데이터에 대한 디코딩이나 증폭, 노이즈 필터링 등과 같은 다양한 처리가 수행될 수 있다.The
비디오 처리부(170)는 비디오 데이터에 대한 처리를 수행하는 구성요소이다. 비디오 처리부(170)에서는 비디오 데이터에 대한 디코딩, 스케일링, 노이즈 필터링, 프레임 레이트 변환, 해상도 변환 등과 같은 다양한 이미지 처리를 수행할 수 있다.The
이상과 같은 방법을 통해 프로세서(120)는 임베딩 행렬 및 소프트맥스 행렬을 포함하는 언어 모델을 성능 저하를 최소화하면서도 데이터가 압축된 제1 프로젝션 행렬, 제2 프로젝션 행렬, 제1 행렬, 제2 행렬 및 제3 행렬을 포함하는 언어 모델로 변환할 수 있다.Through the above-described method, the
이하에서는 이상과 같이 압축된 언어 모델을 통해 추천 워드를 제공하는 방법을 설명한다.Hereinafter, a method of providing a recommended word through the compressed language model will be described.
도 2는 본 발명의 다른 실시 예에 따른 전자 장치(200)를 설명하기 위한 블록도이다. 도 2에 도시된 바와 같이, 전자 장치(200)는 스토리지(210) 및 프로세서(220)를 포함한다.2 is a block diagram illustrating an
전자 장치(200)는 추천 워드를 제공할 수 있는 장치일 수 있다. 예를 들어, 전자 장치(200)는 사용자의 발화를 입력받고, 사용자의 발화 다음으로 이어질 추천 워드를 제공할 수 있다. 좀더 구체적인 예를 들면, 전자 장치(200)는 사용자의 "오늘은 날씨가 ~"라는 발화가 입력되면, "맑다", "춥네"와 같은 추천 워드를 제공할 수 있다.The
전자 장치(200)는 데스크탑 PC, 노트북, 스마트폰, 태블릿 PC, 서버 등일 수 있다. 특히, 전자 장치(200)는 저장 용량이 작은 장치라도 무방하다.The
스토리지(210)는 임베딩 행렬로 이용되는 제1 프로젝션 행렬, 제1 행렬, 제2 행렬 및 제3 행렬 및 소프트맥스 행렬로 이용되는 제2 프로젝션 행렬, 제1 행렬, 제2 행렬 및 제3 행렬을 포함하는 언어 모델을 저장할 수 있다. 즉, 스토리지(210)는 도 1a 및 도 1b에서 설명한 압축된 언어 모델을 저장할 수 있다.The
프로세서(220)는 전자 장치(200)의 동작을 전반적으로 제어한다.
일 실시 예에 따라 프로세서(220)는 디지털 시그널 프로세서(digital signal processor(DSP), 마이크로 프로세서(microprocessor), TCON(Time controller)으로 구현될 수 있다. 다만, 이에 한정되는 것은 아니며, 중앙처리장치(central processing unit(CPU)), MCU(Micro Controller Unit), MPU(micro processing unit), 컨트롤러(controller), 어플리케이션 프로세서(application processor(AP)), 또는 커뮤니케이션 프로세서(communication processor(CP)), ARM 프로세서 중 하나 또는 그 이상을 포함하거나, 해당 용어로 정의될 수 있다. 또한, 프로세서(140)는 프로세싱 알고리즘이 내장된 SoC(System on Chip), LSI(large scale integration)로 구현될 수도 있고, FPGA(Field Programmable gate array) 형태로 구현될 수도 있다.According to one embodiment, the
프로세서(220)는 제1 워드가 입력되면 제1 워드에 대응되는 제1 벡터를 제1 프로젝션 행렬, 제1 행렬, 제2 행렬 및 제3 행렬에 기초하여 벡터 공간으로 매핑시킨 제1 데이터를 획득할 수 있다. 예를 들어, 프로세서(220)는 사용자로부터 "I"라는 워드가 입력되면 "I"에 대응되는 제1 벡터를 제1 프로젝션 행렬, 제1 행렬, 제2 행렬 및 제3 행렬에 곱하여 고차원의 제1 데이터를 획득할 수 있다.When the first word is inputted, the
프로세서(220)는 제1 데이터를 제2 프로젝션 행렬, 제1 행렬, 제2 행렬 및 제3 행렬에 기초하여 제2 벡터를 획득할 수 있다. 예를 들어, 제2 벡터는 각 열의 값이 0에서 1사이의 값을 가지며, 모든 열의 값을 더하면 1이 될 수 있다.The
프로세서(220)는 제2 벡터에 기초하여 추천 워드를 제공할 수 있다. 예를 들어, 프로세서(220)는 제2 벡터의 엘리먼트의 값 중 가장 큰 값이 위치한 열에 대응되는 워드를 제1 추천 워드로 제공하고, 제2 벡터의 엘리먼트의 값 중 두 번째로 큰 값이 위치한 열에 대응되는 워드를 제2 추천 워드로 제공할 수 있다. 예를 들어, 프로세서(220)는 제1 추천 워드로 "am"을 제공하고, 제2 추천 워드로 "was"를 추천할 수 있다.The
다만, 이에 한정되는 것은 아니며, 프로세서(220)는 얼마든지 다른 개수의 추천 워드를 제공할 수도 있다.However, the present invention is not limited thereto, and the
프로세서(220)는 제1 워드가 입력된 후 제2 워드가 입력되면 제2 워드에 대응되는 제3 벡터를 제1 프로젝션 행렬, 제1 행렬, 제2 행렬 및 제3 행렬에 기초하여 벡터 공간으로 매핑시킨 제2 데이터를 획득할 수 있다.When a second word is input after the first word is inputted, the
예를 들어, 프로세서(220)는 "I"가 입력된 후, "am"이 입력되면 "am"에 대응되는 제3 벡터를 제1 프로젝션 행렬, 제1 행렬, 제2 행렬 및 제3 행렬에 곱하여 고차원의 제2 데이터를 획득할 수 있다. 즉, 프로세서(220)는 이전에 입력된 "I" 및 현재 입력된 "am"을 모두 고려할 수 있다.For example, when the " am "is inputted after the" I "is inputted, the
프로세서(220)는 제1 데이터 및 제2 데이터에 기초하여 제3 데이터를 생성할 수 있다. 예를 들어, 프로세서(220)는 LSTM(Long-Short term Memory) 방식에 기초하여 제1 데이터 및 제2 데이터로부터 제3 데이터를 생성할 수 있다. 또는, 프로세서(220)는 제1 데이터 및 제2 데이터를 가중합하여 제3 데이터를 생성할 수도 있다.The
프로세서(220)는 제3 데이터를 제2 프로젝션 행렬, 제1 행렬, 제2 행렬 및 제3 행렬에 기초하여 제4 벡터를 획득할 수 있다.The
예를 들어, 프로세서(220)는 제2 프로젝션 행렬, 제1 행렬, 제2 행렬 및 제3 행렬의 곱의 전치 행렬을 획득하고, 제3 데이터를 획득한 전치 행렬과 곱하여 제4 벡터를 획득할 수 있다. 예를 들어, 제4 벡터는 각 열의 값이 0에서 1사이의 값을 가지며, 모든 열의 값을 더하면 1이 될 수 있다.For example, the
프로세서(220)는 제4 벡터에 기초하여 추천 워드를 제공할 수 있다. 예를 들어, 프로세서(220)는 제4 벡터의 엘리먼트의 값 중 가장 큰 값이 위치한 열에 대응되는 워드를 제1 추천 워드로 제공하고, 제4 벡터의 엘리먼트의 값 중 두 번째로 큰 값이 위치한 열에 대응되는 워드를 제2 추천 워드로 제공할 수 있다. 예를 들어, 프로세서(220)는 제1 추천 워드로 "a"을 제공하고, 제2 추천 워드로 "busy"를 추천할 수 있다.
다만, 이에 한정되는 것은 아니며, 프로세서(220)는 더 많은 워드를 입력받고 추천 워드를 제공할 수도 있다. 여기서, 프로세서(220)가 참조하는 이전 시간의 워드의 개수는 제한이 있을 수 있다. 예를 들어, 프로세서(220)는 현재의 워드가 입력되면 이전 시간에 입력된 3개 이내의 워드만을 참조할 수도 있다.However, the present invention is not limited thereto, and the
또한, 이전 시간도 현재로부터 기설정된 시간 이내일 수 있다. 예를 들면, 프로세서(220)는 현재의 워드가 입력되면 현재 시점으로부터 10초 이전으로부터 현재 시점까지 입력된 워드만을 참조할 수도 있다.Also, the previous time may be within a predetermined time from the current time. For example, when the current word is input, the
또는, 프로세서(220)는 하나의 워드를 입력받고 추천 워드를 제공할 수도 있다. 즉, 프로세서(220)는 이전 시간에 입력된 워드를 참조하지 않을 수도 있다.Alternatively, the
한편, 전자 장치(200)는 입력부(미도시) 및 출력부(미도시)를 더 포함할 수 있다. 입력부는 사용자로부터 워드를 입력받기 위한 구성으로서, 마이크, 키보드 등일 수 있다. 출력부는 추천 워드를 제공하기 위한 구성으로서, 디스플레이, 스피커 등일 수 있다.Meanwhile, the
또한, 프로세서(220)의 구조는 도 1b의 프로세서(120)의 구조와 동일할 수 있으며, 구체적인 설명은 생략한다.In addition, the structure of the
이상과 같은 방법으로 전자 장치(200)는 추천 워드를 제공할 수 있다. 한편, 전자 장치(200)는 제1 프로젝션 행렬, 제2 프로젝션 행렬, 제1 행렬, 제2 행렬 및 제3 행렬을 포함하는 언어 모델을 저장하기 때문에, 임베딩 행렬로서 이용될 제1 프로젝션 행렬, 제1 행렬, 제2 행렬 및 제3 행렬을 곱하는 제1 연산, 제2 프로젝션 행렬, 제1 행렬, 제2 행렬 및 제3 행렬을 곱하는 제2 연산 및 소프트맥스 행렬로서 이용될 제2 연산에 따른 행렬의 전치 행렬을 산출하는 제3 연산이 추가적으로 수행될 수 있다. 다만, 이러한 연산 시간은 매우 짧기 때문에 추천 워드를 제공하는 것에 큰 문제가 되지 않는다.In this way, the
한편, 도 1a 및 도 1b의 전자 장치(100)와 도 2의 전자 장치(200)가 별개인 것으로 설명하였으나, 하나의 전자 장치로 구현될 수도 있다.While the
이하에서는 다양한 도면을 통해 언어 모델을 압축하기 위한 전자 장치의 동작 및 추천 워드를 제공하기 위한 전자 장치의 동작을 좀더 구체적으로 설명한다.Hereinafter, the operation of the electronic device for compressing the language model through various drawings and the operation of the electronic device for providing the recommended word will be described in more detail.
도 3a 및 도 3b는 종래 기술에 따른 RNN 학습을 설명하기 위한 도면들이다.3A and 3B are diagrams for explaining RNN learning according to the prior art.
도 3a에 도시된 바와 같이, 프로세서(120)는 입력된 워드에 대응되는 벡터를 벡터 공간으로 매핑시키는 Word Embedding을 수행할 수 있다. 이때, 임베딩 행렬(Wembed)이 이용될 수 있다.As shown in FIG. 3A, the
프로세서(120)는 t-3의 시간에 입력된 제1 워드, t-2의 시간에 입력된 제2 워드 및 t-1의 시간에 입력된 제3 워드를 순차적으로 벡터 공간으로 매핑하고, Recurrent Hidden layer 단계에서 벡터 공간으로 매핑된 제1 데이터, 제2 데이터 및 제3 데이터에 기초하여 제4 데이터를 생성할 수 있다. 예를 들어, 프로세서(120)는 LSTM(Long-Short term Memory) 방식 또는 가중합 방식에 기초하여 제1 데이터, 제2 데이터 및 제3 데이터에 기초하여 제4 데이터를 생성할 수 있다.The
그리고, 프로세서(120)는 Softmax layer 단계에서 벡터 공간의 제4 데이터를 복원 벡터로 변환할 수 있다. 이때, 소프트맥스 행렬(Wsoftmax)이 이용될 수 있다. 프로세서(120)는 복원 벡터와 t의 시간에 입력될 제4 워드를 비교하여 임베딩 행렬 및 소프트맥스 행렬의 엘리먼트를 업데이트할 수 있다. 이러한 과정을 학습이라 한다.The
도 3b는 학습 과정을 좀더 구체적인 기본 데이터의 예로서 설명하기 위한 도면으로, 도 3a와 연계하여 설명한다.FIG. 3B is a diagram for explaining the learning process as an example of more specific basic data, which will be described in connection with FIG. 3A.
도 3b의 첫 번째 문장을 학습하는 경우, 프로세서(120)는 t-3의 시간에 입력된 "I", t-2의 시간에 입력된 "hope" 및 t-1의 시간에 입력된 "I"를 순차적으로 벡터 공간으로 매핑하고, 벡터 공간으로 매핑된 제1 데이터, 제2 데이터 및 제3 데이터에 기초하여 제4 데이터를 생성할 수 있다.When learning the first sentence of FIG. 3B, the
그리고, 프로세서(120)는 벡터 공간의 제4 데이터를 복원 벡터로 변환하며, 복원 벡터와 t의 시간에 입력될 "shall"을 비교하여 임베딩 행렬 및 소프트맥스 행렬의 엘리먼트를 업데이트할 수 있다. 즉, 임베딩 행렬 및 소프트맥스 행렬의 엘리먼트는 "I", "hope", "I"가 순차적으로 입력되면 "shall"이 출력되도록 업데이트될 수 있다.The
또한, t+1의 시간에는 "I", "hope", "I", "shall"이 순차적으로 입력되고, 프로세서(120)는 동일한 방법으로 학습을 수행할 수 있다. 즉, 임베딩 행렬 및 소프트맥스 행렬의 엘리먼트는 "I", "hope", "I", "shall"이 순차적으로 입력되면 "succeed"가 출력되도록 업데이트될 수 있다. 이러한 학습을 하나의 문장에 대해 완료하면, 프로세서(120)는 나머지 4개의 문장에 대하여도 학습을 수행한다."I", "hope", "I", and "shall" are sequentially input at
학습에 따라 언어 모델은 최적의 추천 워드가 제공되도록 생성될 수 있다. 예를 들어, 도 3b의 기본 데이터를 RNN 학습한 언어 모델을 이용하는 경우, t-1의 시간에 "I"가 입력되면 "am"이 추천 워드로서 제공될 수 있다. 이는, 5개의 문장에서 "I"가 첫 번째 워드인 경우에 두 번째 워드는 "hope", "am", "did, "am", "am"이며, 학습 과정에서 "am"이 세 번 반복됨에 따라 "I"의 다음으로 가장 적절한 추천 워드가 "m"이 되도록 임베딩 행렬 및 소프트맥스 행렬의 엘리먼트가 업데이트되었기 때문이다.Depending on the learning, the language model may be generated to provide an optimal recommendation word. For example, when the language model obtained by RNN learning of the basic data of FIG. 3B is used, "am" may be provided as a recommended word if "I" is input at time t-1. This means that if the "I" is the first word in the five sentences, the second word is "hope", "am", "did", "am" Because the elements of the embedding matrix and the soft-max matrix have been updated such that the most appropriate recommendation word next to "I " is" m "
도 3b는 설명의 편의를 위한 것으로, 실제로는 훨씬 방대한 수의 문장을 학습하여 임베딩 행렬 및 소프트맥스 행렬의 엘리먼트가 업데이트될 수 있다.FIG. 3B is for convenience of explanation. In practice, a much larger number of sentences can be learned so that the elements of the embedding matrix and the soft-max matrix can be updated.
도 4는 본 발명의 일 실시 예에 따른 압축 방법을 설명하기 위한 도면이다.4 is a view for explaining a compression method according to an embodiment of the present invention.
먼저, 도 4의 Knowledge Distillation은 복수의 언어 모델을 생성하고, 복수의 언어 모델 각각으로부터 출력되는 추천 워드의 평균을 이용하여 언어 모델의 성능을 향상시키기 위한 방법을 의미한다.First, the Knowledge Distillation in FIG. 4 means a method for generating a plurality of language models and improving the performance of the language model using the average of the recommended words output from each of the plurality of language models.
Compression & Retraining은 임베딩 행렬 및 소프트맥스 행렬을 포함하는 언어 모델을 압축하기 위한 방법을 의미하며, 두 단계로 구분될 수 있다.Compression & Retraining means a method for compressing a language model including an embedding matrix and a soft max matrix, and can be divided into two stages.
첫 번째 단계는 임베딩 행렬을 행렬의 크기가 동일한 제1 프로젝션 행렬 및 공유 행렬의 곱으로 변환하고, 소프트맥스 행렬의 전치 행렬을 행렬의 크기가 동일한 제2 프로젝션 행렬 및 공유 행렬로 변환하며, RNN 학습을 통해 제1 프로젝션 행렬, 제2 프로젝션 행렬 및 공유 행렬의 엘리먼트를 업데이트하고, 성능을 판단한다. 이러한 과정을 다양한 크기의 공유 행렬에 대하여 반복 수행한 후, 성능 저하가 미미하면서도 압축 효율이 좋은 공유 행렬의 크기를 획득하고, 획득한 공유 행렬을 이용하여 1차 압축된 언어 모델을 생성할 수 있다.The first step is to convert the embedding matrix into a product of the first projection matrix and the shared matrix having the same matrix size, transform the transpose matrix of the soft max matrix into a second projection matrix and a shared matrix having the same matrix size, Updates the elements of the first projection matrix, the second projection matrix, and the shared matrix through the first projection matrix, the second projection matrix, and the shared matrix. This process is repeated for a shared matrix of various sizes, and then a size of a shared matrix with a small compression efficiency is obtained, and a primary compressed language model is generated using the obtained shared matrix .
두 번째 단계는 공유 행렬을 SVD를 통해 제1 행렬, 제2 행렬 및 제3 행렬로 변환하고, RNN 학습을 통해 제1 프로젝션 행렬, 제2 프로젝션 행렬, 제1 행렬, 제2 행렬 및 제3 행렬의 엘리먼트를 업데이트하여 2차 압축된 언어 모델을 생성하는 단계이다.The second step is to transform the shared matrix into a first matrix, a second matrix and a third matrix through SVD, and the first projection matrix, the second projection matrix, the first matrix, the second matrix and the third matrix To generate a second-compressed language model.
도 5는 본 발명의 일 실시 예에 따른 압축된 언어 모델의 성능 및 압축 효율을 나타내는 도면이다. 도 5의 PP는 Word Perplexity를 의미하고, CR은 Compression Rate를 의미한다.5 illustrates performance and compression efficiency of a compressed language model according to an embodiment of the present invention. 5, PP means Word Perplexity, and CR means Compression Rate.
먼저, 기본 언어 모델을 이용한 Baseline의 경우, PP는 56.55이고, 데이터 크기는 56.76이다. 여기서, 도 4의 KD(Knowledge Distillation)를 적용한 경우 성능이 향상되어 PP는 55.76이며, 이는 Baseline보다 감소한 값이다.First, for Baseline using the basic language model, the PP is 56.55 and the data size is 56.76. Here, when the knowledge distillation (KD) of FIG. 4 is applied, the performance is improved and the PP is 55.76, which is a value lower than the baseline.
그리고, 1차 압축된 언어 모델을 이용하는 Shared Matrix의 경우 PP는 55.07이고, 데이터의 크기는 33.87이다. 즉, Shared Matrix의 경우 PP는 Baseline 또는 KD의 경우와 비슷하나, CR 1.68만큼 데이터의 크기가 감소했다.In the case of Shared Matrix using the primary compressed language model, the PP is 55.07 and the data size is 33.87. In the case of Shared Matrix, PP is similar to Baseline or KD, but the size of the data is reduced by CR 1.68.
또한, 2차 압축된 언어 모델을 이용하는 Low-Rank, Retrain의 경우 PP는 59.78이고, 데이터의 크기는 14.80이다. 즉, Low-Rank, Retrain의 경우 PP는 Baseline 또는 KD의 경우보다 약간 증가하여 성능이 약간 저하되었으나, CR 3.84만큼 데이터의 크기가 감소했으며, 이는 Shared Matrix의 경우보다 압축률이 높다.In the case of Low-Rank and Retrain using the second-language language model, the PP is 59.78 and the data size is 14.80. In other words, in the case of low-rank and retrain, PP slightly increased in performance compared to baseline or KD, but the data size decreased by CR 3.84, which is higher than that of Shared Matrix.
2차 압축된 언어 모델에서 프로세서(120)는 제1 프로젝션 행렬, 제2 프로젝션 행렬, 제1 행렬, 제2 행렬 및 제3 행렬의 엘리먼트를 양자화(Quantization)하여 3차 압축된 언어 모델을 생성할 수 있다. 예를 들어, 프로세서(120)는 제1 프로젝션 행렬, 제2 프로젝션 행렬, 제1 행렬, 제2 행렬 및 제3 행렬의 4바이트의 엘리먼트를 2바이트로 양자화하여 3차 압축된 언어 모델을 생성할 수 있다.In the secondary compressed language model, the
도 5에 도시된 바와 같이, 2차 압축된 언어 모델에서 엘리먼트가 양자화된 언어 모델을 이용하는 Quantization의 경우 PP는 59.78이고, 데이터의 크기는 7.40이다. 즉, Quantization의 경우 PP는 Low-Rank, Retrain의 경우와 동일하고, CR 7.68만큼 데이터의 크기가 감소했으며, 이는 Low-Rank, Retrain의 경우보다 압축률이 높다.As shown in FIG. 5, in the case of quantization using the language model in which the elements are quantized in the secondary compressed language model, PP is 59.78 and the data size is 7.40. That is, in the case of quantization, the PP is the same as that of low-rank and retrain, and the data size is reduced by CR 7.68, which is higher than that of low-rank and retrain.
이상과 같이 임베딩 행렬 및 소프트맥스 행렬 각각을 행렬의 크기가 작은 복수의 행렬로 분할하고, 각 엘리먼트를 양자화하여 데이터를 압축하면서도, 성능 저하를 최소화할 수 있다.As described above, each of the embedding matrix and the soft-max matrix is divided into a plurality of matrices each having a small matrix size, and each element is quantized to compress data, thereby minimizing performance degradation.
도 6은 본 발명의 일 실시 예에 따른 전자 장치의 언어 모델을 압축하기 위한 동작 방법을 설명하기 위한 흐름도이다. 여기서, 전자 장치는 복수의 문장(sentence)을 포함하는 기본 데이터로 RNN(Recurrent Neural Network) 학습(training)된 임베딩 행렬(embedding matrix) 및 소프트맥스 행렬(softmax matrix)을 포함하는 언어 모델을 저장할 수 있다.6 is a flowchart illustrating an operation method for compressing a language model of an electronic device according to an embodiment of the present invention. Here, the electronic device can store a language model including an embedding matrix and a softmax matrix, which are RNN (Recurrent Neural Network) training, as basic data including a plurality of sentences have.
먼저, 임베딩 행렬을 행렬의 크기가 동일한 제1 프로젝션 행렬(projection matrix) 및 공유 행렬의 곱으로 변환하고, 소프트맥스 행렬의 전치 행렬을 행렬의 크기가 동일한 제2 프로젝션 행렬 및 공유 행렬로 변환한다(S610). 그리고, 제1 프로젝션 행렬, 제2 프로젝션 행렬 및 공유 행렬을 기본 데이터로 RNN 학습하여 제1 프로젝션 행렬, 제2 프로젝션 행렬 및 공유 행렬 각각의 엘리먼트를 업데이트한다(S620).First, an embedding matrix is transformed into a product of a first projection matrix and a shared matrix having the same matrix size, and a transpose matrix of the soft-max matrix is transformed into a second projection matrix and a shared matrix having the same matrix size ( S610). In operation S620, the first projection matrix, the second projection matrix, and the shared matrix are RNN learned as basic data to update the elements of the first projection matrix, the second projection matrix, and the shared matrix.
그리고, 테스트 모듈에 기초하여 제1 프로젝션 행렬, 제2 프로젝션 행렬 및 공유 행렬에 대한 워드 퍼플렉시티(word perplexity)를 산출하는 단계, 워드 퍼플렉시티가 기설정된 값 이상이면 공유 행렬보다 행렬의 크기(size)가 큰 새로운 공유 행렬을 획득하며, 워드 퍼플렉시티가 기설정된 값 미만이면 공유 행렬보다 행렬의 크기가 작은 새로운 공유 행렬을 획득하는 단계 및 획득된 새로운 공유 행렬을 이용하여 제1 프로젝션 행렬, 제2 프로젝션 행렬 및 공유 행렬을 재산출하는 단계를 더 포함할 수 있다.Calculating a word perplexity for the first projection matrix, the second projection matrix and the common matrix based on the test module; if the word perparency is greater than or equal to a predetermined value, acquiring a new shared matrix having a size smaller than the shared matrix if the word-polarity is less than a preset value, and acquiring a new shared matrix having a smaller matrix size than the shared matrix if the word- , A second projection matrix and a shared matrix.
또한, 테스트 모듈에 기초하여 임베딩 행렬 및 소프트맥스 행렬에 대한 기준 워드 퍼플렉시티를 산출하는 단계 및 기준 워드 퍼플렉시티에 기초하여 기설정된 값을 결정하는 단계를 더 포함할 수 있다.The method may further include calculating a reference wordperformance for the embedding matrix and the soft-max matrix based on the test module, and determining a predetermined value based on the reference wordperformance.
여기서, 재산출하는 단계는 워드 퍼플렉시티가 기설정된 값 미만인 복수의 공유 행렬 중 행렬의 크기가 가장 작은 공유 행렬로 제1 프로젝션 행렬, 제2 프로젝션 행렬 및 공유 행렬을 재산출하고, 재산출된 제1 프로젝션 행렬, 제2 프로젝션 행렬 및 공유 행렬로 압축된 언어 모델을 생성하는 단계를 더 포함할 수 있다.Here, the property shipment step re-calculates the first projection matrix, the second projection matrix, and the shared matrix with the shared matrix having the smallest matrix size among the plurality of shared matrices whose word-polarity is less than a preset value, The method may further comprise generating a compressed language model with a first projection matrix, a second projection matrix, and a shared matrix.
한편, SVD(Singular Value Decomposition)를 이용하여 공유 행렬을 제1 행렬, 제2 행렬 및 제3 행렬로 변환하는 단계, 제1 프로젝션 행렬, 제2 프로젝션 행렬, 제1 행렬, 제2 행렬 및 제3 행렬을 기본 데이터로 RNN 학습하여 제1 프로젝션 행렬, 제2 프로젝션 행렬, 제1 행렬, 제2 행렬 및 제3 행렬 각각의 엘리먼트를 업데이트하는 단계 및 엘리먼트가 업데이트된 제1 프로젝션 행렬, 제2 프로젝션 행렬, 제1 행렬, 제2 행렬 및 제3 행렬로 압축된 언어 모델을 생성하는 단계를 더 포함할 수 있다.The method includes the steps of transforming a shared matrix into a first matrix, a second matrix and a third matrix using SVD (Singular Value Decomposition), a first projection matrix, a second projection matrix, a first matrix, a second matrix, Updating an element of each of the first projection matrix, the second projection matrix, the first matrix, the second matrix and the third matrix by RNN learning of the matrix as basic data, and updating the elements of the first projection matrix, the second projection matrix , Generating a language model compressed with the first matrix, the second matrix and the third matrix.
또한, 복수의 문장 중 하나의 문장에 포함된 제1 워드에 대응되는 제1 벡터를 제1 랜덤 행렬에 기초하여 벡터 공간으로 매핑시킨 제1 데이터를 획득하는 단계, 문장에 포함되고 제1 워드 다음의 제2 워드가 입력되면 제2 워드에 대응되는 제2 벡터를 제1 랜덤 행렬에 기초하여 벡터 공간으로 매핑시킨 제2 데이터를 획득하는 단계, 제1 데이터 및 제2 데이터에 기초하여 제3 데이터를 생성하는 단계, 제3 데이터를 제2 랜덤 행렬에 기초하여 복원 벡터를 획득하는 단계 및 복원 벡터 및 제2 워드 다음의 제3 워드에 대응되는 제3 벡터 간의 오차에 기초하여 제1 랜덤 행렬 및 제2 랜덤 행렬의 엘리먼트를 업데이트하여 학습하는 단계를 더 포함할 수 있다.The method may further include obtaining first data obtained by mapping a first vector corresponding to a first word included in one of a plurality of sentences into a vector space based on a first random matrix, Acquiring second data obtained by mapping a second vector corresponding to a second word to a vector space based on a first random matrix when a second word of the second word is input, Obtaining a third data based on the second random matrix and obtaining a first random matrix based on the error between the restored vector and a third vector corresponding to the third word after the second word, And updating the element of the second random matrix to learn.
여기서, 복수의 문장 중 나머지 문장에 기초하여 제1 랜덤 행렬 및 제2 랜덤 행렬 각각의 엘리먼트를 업데이트하는 단계 및 나머지 문장에 기초하여 엘리먼트가 업데이트된 제1 랜덤 행렬 및 제2 랜덤 행렬을 각각 임베딩 행렬 및 소프트맥스 행렬로서 저장하는 단계를 더 포함할 수 있다.Updating the elements of each of the first random matrix and the second random matrix based on the remaining one of the plurality of sentences, and writing the first random matrix and the second random matrix, whose elements are updated based on the remaining sentence, And storing them as a soft-max matrix.
한편, 임베딩 행렬 및 소프트맥스 행렬의 전치 행렬은 크기가 동일할 수 있다.On the other hand, the transpose matrix of the embedding matrix and the soft max matrix may have the same size.
도 7은 본 발명의 일 실시 예에 따른 전자 장치의 추천 워드를 제공하기 위한 동작 방법을 설명하기 위한 흐름도이다. 여기서, 전자 장치는 임베딩 행렬로 이용되는 제1 프로젝션 행렬, 제1 행렬, 제2 행렬 및 제3 행렬 및 소프트맥스 행렬로 이용되는 제2 프로젝션 행렬, 제1 행렬, 제2 행렬 및 제3 행렬을 포함하는 언어 모델을 저장할 수 있다.7 is a flowchart illustrating an operation method for providing a recommendation word of an electronic device according to an embodiment of the present invention. Here, the electronic device includes a first projection matrix used as an embedding matrix, a second projection matrix used as a first matrix, a second matrix and a third matrix and a soft max matrix, a first matrix, a second matrix and a third matrix You can save the language model that contains it.
먼저, 제1 워드가 입력되면 제1 워드에 대응되는 제1 벡터를 임베딩 행렬로 이용되는 제1 프로젝션 행렬, 제1 행렬, 제2 행렬 및 제3 행렬에 기초하여 벡터 공간으로 매핑시킨 제1 데이터를 획득한다(S710). 그리고, 제1 데이터를 소프트맥스 행렬로 이용되는 제2 프로젝션 행렬, 제1 행렬, 제2 행렬 및 제3 행렬에 기초하여 제2 벡터를 획득한다(S720). 그리고, 제2 벡터에 기초하여 추천 워드를 제공한다(S730).First, when a first word is input, a first vector corresponding to a first word is mapped to a vector space based on a first projection matrix used as an embedded matrix, a first matrix, a second matrix, and a third matrix, (S710). Then, the second vector is obtained based on the second projection matrix, the first matrix, the second matrix, and the third matrix, which are used as the soft-max matrix of the first data (S720). Then, a recommendation word is provided based on the second vector (S730).
그리고, 제1 워드가 입력된 후 제2 워드가 입력되면 제2 워드에 대응되는 제3 벡터를 제1 프로젝션 행렬, 제1 행렬, 제2 행렬 및 제3 행렬에 기초하여 벡터 공간으로 매핑시킨 제2 데이터를 획득하는 단계, 제1 데이터 및 제2 데이터에 기초하여 제3 데이터를 생성하는 단계, 제3 데이터를 제2 프로젝션 행렬, 제1 행렬, 제2 행렬 및 제3 행렬에 기초하여 제4 벡터를 획득하는 단계 및 제4 벡터에 기초하여 추천 워드를 제공하는 단계를 더 포함할 수 있다.When a second word is input after the first word is input, a third vector corresponding to the second word is mapped into a vector space based on the first projection matrix, the first matrix, the second matrix, and the third matrix. 2 data, generating third data based on the first data and the second data, generating third data based on the second projection matrix, the first matrix, the second matrix and the third matrix, Obtaining the vector and providing a recommendation word based on the fourth vector.
이상과 같은 본 발명의 다양한 실시 예에 따르면, 전자 장치는 RNN(Recurrent Neural Network) 학습(training)된 언어 모델의 데이터를 압축하며, 저장 공간이 상대적으로 작은 전자 장치가 압축된 언어 모델을 저장하며, 압축된 언어 모델에 기초한 추천 워드를 성능 저하를 최소화하면서 제공할 수 있다.According to various embodiments of the present invention, the electronic device compresses data of a language model of a Recurrent Neural Network (RNN), stores a compressed language model of an electronic device having a relatively small storage space, , The recommendation word based on the compressed language model can be provided with minimal degradation of performance.
한편, 본 발명의 일시 예에 따르면, 이상에서 설명된 다양한 실시 예들은 기기(machine)(예: 컴퓨터)로 읽을 수 있는 저장 매체(machine-readable storage media)에 저장된 명령어를 포함하는 소프트웨어로 구현될 수 있다. 기기는, 저장 매체로부터 저장된 명령어를 호출하고, 호출된 명령어에 따라 동작이 가능한 장치로서, 개시된 실시 예들에 따른 전자 장치(예: 전자 장치(A))를 포함할 수 있다. 명령이 프로세서에 의해 실행될 경우, 프로세서가 직접, 또는 프로세서의 제어 하에 다른 구성요소들을 이용하여 명령에 해당하는 기능을 수행할 수 있다. 명령은 컴파일러 또는 인터프리터에 의해 생성 또는 실행되는 코드를 포함할 수 있다. 기기로 읽을 수 있는 저장매체는, 비일시적(non-transitory) 저장매체의 형태로 제공될 수 있다. 여기서, '비일시적'은 저장매체가 신호(signal)를 포함하지 않으며 실재(tangible)한다는 것을 의미할 뿐 데이터가 저장매체에 반영구적 또는 임시적으로 저장됨을 구분하지 않는다.Meanwhile, in accordance with one exemplary embodiment of the present invention, the various embodiments described above may be implemented with software that includes instructions stored on a machine-readable storage medium readable by a machine (e.g., a computer) . The device may include an electronic device (e.g., electronic device A) in accordance with the disclosed embodiments, which is a device capable of calling stored instructions from the storage medium and operating according to the called instructions. When an instruction is executed by a processor, the processor may perform functions corresponding to the instruction, either directly or under the control of the processor, using other components. The instructions may include code generated or executed by the compiler or interpreter. A device-readable storage medium may be provided in the form of a non-transitory storage medium. Here, 'non-temporary' means that the storage medium does not include a signal and is tangible, but does not distinguish whether data is stored semi-permanently or temporarily on the storage medium.
또한, 본 발명의 일 실시 예에 따르면, 이상에서 설명된 다양한 실시 예들에 따른 방법은 컴퓨터 프로그램 제품(computer program product)에 포함되어 제공될 수 있다. 컴퓨터 프로그램 제품은 상품으로서 판매자 및 구매자 간에 거래될 수 있다. 컴퓨터 프로그램 제품은 기기로 읽을 수 있는 저장 매체(예: compact disc read only memory (CD-ROM))의 형태로, 또는 어플리케이션 스토어(예: 플레이 스토어TM)를 통해 온라인으로 배포될 수 있다. 온라인 배포의 경우에, 컴퓨터 프로그램 제품의 적어도 일부는 제조사의 서버, 어플리케이션 스토어의 서버, 또는 중계 서버의 메모리와 같은 저장 매체에 적어도 일시 저장되거나, 임시적으로 생성될 수 있다.Also, in accordance with one embodiment of the present invention, a method according to various embodiments described above may be provided in a computer program product. A computer program product can be traded between a seller and a buyer as a product. A computer program product may be distributed in the form of a machine readable storage medium (eg, compact disc read only memory (CD-ROM)) or distributed online through an application store (eg PlayStore ™). In the case of on-line distribution, at least a portion of the computer program product may be temporarily stored, or temporarily created, on a storage medium such as a manufacturer's server, a server of an application store, or a memory of a relay server.
또한, 본 발명의 일 실시 예에 따르면, 이상에서 설명된 다양한 실시 예들은 소프트웨어(software), 하드웨어(hardware) 또는 이들의 조합을 이용하여 컴퓨터(computer) 또는 이와 유사한 장치로 읽을 수 있는 기록 매체 내에서 구현될 수 있다. 일부 경우에 있어 본 명세서에서 설명되는 실시 예들이 프로세서 자체로 구현될 수 있다. 소프트웨어적인 구현에 의하면, 본 명세서에서 설명되는 절차 및 기능과 같은 실시 예들은 별도의 소프트웨어 모듈들로 구현될 수 있다. 소프트웨어 모듈들 각각은 본 명세서에서 설명되는 하나 이상의 기능 및 동작을 수행할 수 있다.In addition, in accordance with one embodiment of the present invention, the various embodiments described above may be embodied in a recording medium readable by a computer or similar device using software, hardware, Lt; / RTI > In some cases, the embodiments described herein may be implemented by the processor itself. According to a software implementation, embodiments such as the procedures and functions described herein may be implemented with separate software modules. Each of the software modules may perform one or more of the functions and operations described herein.
한편, 상술한 다양한 실시 예들에 따른 기기의 프로세싱 동작을 수행하기 위한 컴퓨터 명령어(computer instructions)는 비일시적 컴퓨터 판독 가능 매체(non-transitory computer-readable medium)에 저장될 수 있다. 이러한 비일시적 컴퓨터 판독 가능 매체에 저장된 컴퓨터 명령어는 특정 기기의 프로세서에 의해 실행되었을 때 상술한 다양한 실시 예에 따른 기기에서의 처리 동작을 특정 기기가 수행하도록 한다. 비일시적 컴퓨터 판독 가능 매체란 레지스터, 캐쉬, 메모리 등과 같이 짧은 순간 동안 데이터를 저장하는 매체가 아니라 반영구적으로 데이터를 저장하며, 기기에 의해 판독(reading)이 가능한 매체를 의미한다. 비일시적 컴퓨터 판독 가능 매체의 구체적인 예로는, CD, DVD, 하드 디스크, 블루레이 디스크, USB, 메모리카드, ROM 등이 있을 수 있다.Meanwhile, computer instructions for performing the processing operations of the device according to various embodiments described above may be stored in a non-transitory computer-readable medium. The computer instructions stored in the non-volatile computer-readable medium cause the particular device to perform the processing operations on the device according to the various embodiments described above when executed by the processor of the particular device. Non-transitory computer readable media is a medium that stores data for a short period of time, such as a register, cache, memory, etc., but semi-permanently stores data and is readable by the device. Specific examples of non-transitory computer readable media include CD, DVD, hard disk, Blu-ray disk, USB, memory card, ROM, and the like.
또한, 상술한 다양한 실시 예들에 따른 구성 요소(예: 모듈 또는 프로그램) 각각은 단수 또는 복수의 개체로 구성될 수 있으며, 전술한 해당 서브 구성 요소들 중 일부 서브 구성 요소가 생략되거나, 또는 다른 서브 구성 요소가 다양한 실시 예에 더 포함될 수 있다. 대체적으로 또는 추가적으로, 일부 구성 요소들(예: 모듈 또는 프로그램)은 하나의 개체로 통합되어, 통합되기 이전의 각각의 해당 구성 요소에 의해 수행되는 기능을 동일 또는 유사하게 수행할 수 있다. 다양한 실시예들에 따른, 모듈, 프로그램 또는 다른 구성 요소에 의해 수행되는 동작들은 순차적, 병렬적, 반복적 또는 휴리스틱하게 실행되거나, 적어도 일부 동작이 다른 순서로 실행되거나, 생략되거나, 또는 다른 동작이 추가될 수 있다.Further, each of the components (for example, modules or programs) according to the above-described various embodiments may be composed of a single entity or a plurality of entities, and some subcomponents of the abovementioned subcomponents may be omitted, The components may be further included in various embodiments. Alternatively or additionally, some components (e.g., modules or programs) may be integrated into a single entity to perform the same or similar functions performed by each respective component prior to integration. Operations performed by a module, program, or other component, in accordance with various embodiments, may be performed sequentially, in parallel, repetitively, or heuristically, or at least some operations may be performed in a different order, .
이상에서는 본 개시의 바람직한 실시 예에 대하여 도시하고 설명하였지만, 본 개시는 상술한 특정의 실시 예에 한정되지 아니하며, 청구범위에서 청구하는 본 개시의 요지를 벗어남이 없이 당해 개시에 속하는 기술분야에서 통상의 지식을 가진 자에 의해 다양한 변형실시가 가능한 것은 물론이고, 이러한 변형실시들은 본 개시의 기술적 사상이나 전망으로부터 개별적으로 이해되어져서는 안될 것이다.While the present invention has been particularly shown and described with reference to preferred embodiments thereof, it is to be understood that the present invention is not limited to the specific embodiments thereof, and that various changes and modifications may be made without departing from the scope of the present invention as defined by the appended claims. It will be understood that various modifications may be made by those skilled in the art without departing from the spirit and scope of the present disclosure.
100 : 전자 장치
110 : 스토리지
120 : 프로세서
130 : 통신부
140 : 사용자 인터페이스부
150 : 디스플레이
160 : 오디오 처리부
170 : 비디오 처리부
200 : 전자 장치
210 : 스토리지
220 : 프로세서100: electronic device 110: storage
120: processor 130:
140: user interface unit 150: display
160: audio processing unit 170: video processing unit
200: electronic device 210: storage
220: Processor
Claims (20)
복수의 문장(sentence)을 포함하는 기본 데이터로 RNN(Recurrent Neural Network) 학습(training)된 임베딩 행렬(embedding matrix) 및 소프트맥스 행렬(softmax matrix)을 포함하는 언어 모델이 저장된 스토리지; 및
상기 임베딩 행렬을 행렬의 크기가 동일한 제1 프로젝션 행렬(projection matrix) 및 공유 행렬의 곱으로 변환하고, 상기 소프트맥스 행렬의 전치 행렬을 행렬의 크기가 동일한 제2 프로젝션 행렬 및 상기 공유 행렬로 변환하며,
상기 제1 프로젝션 행렬, 상기 제2 프로젝션 행렬 및 상기 공유 행렬을 상기 기본 데이터로 상기 RNN 학습하여 상기 제1 프로젝션 행렬, 상기 제2 프로젝션 행렬 및 상기 공유 행렬 각각의 엘리먼트(element)를 업데이트하는 프로세서;를 포함하는, 전자 장치.An electronic device for compressing a language model,
A storage for storing a language model including an embedding matrix and a softmax matrix RNN (Recurrent Neural Network) training with basic data including a plurality of sentences; And
Transforming the embedding matrix into a product of a first projection matrix and a shared matrix having the same matrix size, transforming a transpose matrix of the soft-max matrix into a second projection matrix and a shared matrix having the same matrix size ,
A processor for performing RNN learning of the first projection matrix, the second projection matrix, and the shared matrix with the basic data to update elements of the first projection matrix, the second projection matrix, and the shared matrix; .
상기 프로세서는,
테스트 모듈에 기초하여 상기 제1 프로젝션 행렬, 상기 제2 프로젝션 행렬 및 상기 공유 행렬에 대한 워드 퍼플렉시티(word perplexity)를 산출하고,
상기 워드 퍼플렉시티가 기설정된 값 이상이면 상기 공유 행렬보다 행렬의 크기(size)가 큰 새로운 공유 행렬을 획득하며, 상기 워드 퍼플렉시티가 상기 기설정된 값 미만이면 상기 공유 행렬보다 행렬의 크기가 작은 새로운 공유 행렬을 획득하고,
상기 획득된 새로운 공유 행렬을 이용하여 상기 제1 프로젝션 행렬, 상기 제2 프로젝션 행렬 및 상기 공유 행렬을 재산출하는, 전자 장치.The method according to claim 1,
The processor comprising:
Calculating a word perplexity for the first projection matrix, the second projection matrix and the sharing matrix based on the test module,
Acquires a new shared matrix having a matrix size larger than the shared matrix if the word-polarity is greater than or equal to a predetermined value, and if the word-polarity is less than the predetermined value, Obtain a small new shared matrix,
And the first projection matrix, the second projection matrix and the shared matrix are re-delivered using the obtained new shared matrix.
상기 프로세서는,
상기 테스트 모듈에 기초하여 상기 임베딩 행렬 및 상기 소프트맥스 행렬에 대한 기준 워드 퍼플렉시티를 산출하고, 상기 기준 워드 퍼플렉시티에 기초하여 상기 기설정된 값을 결정하는, 전자 장치.3. The method of claim 2,
The processor comprising:
Calculate a reference word power for the embedded matrix and the soft-max matrix based on the test module, and determine the predetermined value based on the reference word power.
상기 프로세서는,
상기 워드 퍼플렉시티가 상기 기설정된 값 미만인 복수의 공유 행렬 중 행렬의 크기가 가장 작은 공유 행렬로 상기 제1 프로젝션 행렬, 상기 제2 프로젝션 행렬 및 상기 공유 행렬을 재산출하고,
재산출된 상기 제1 프로젝션 행렬, 상기 제2 프로젝션 행렬 및 상기 공유 행렬로 압축된 언어 모델을 생성하는, 전자 장치.The method of claim 3,
The processor comprising:
The first projection matrix, the second projection matrix, and the shared matrix to a shared matrix having the smallest matrix size among the plurality of shared matrices having the word-polarity less than the predetermined value,
And generates a re-computed first language matrix with the first projection matrix, the second projection matrix and the shared matrix.
상기 프로세서는,
SVD(Singular Value Decomposition)를 이용하여 상기 공유 행렬을 제1 행렬, 제2 행렬 및 제3 행렬로 변환하고,
상기 제1 프로젝션 행렬, 상기 제2 프로젝션 행렬, 상기 제1 행렬, 상기 제2 행렬 및 상기 제3 행렬을 상기 기본 데이터로 상기 RNN 학습하여 상기 제1 프로젝션 행렬, 상기 제2 프로젝션 행렬, 상기 제1 행렬, 상기 제2 행렬 및 상기 제3 행렬 각각의 엘리먼트를 업데이트하며,
상기 엘리먼트가 업데이트된 상기 제1 프로젝션 행렬, 상기 제2 프로젝션 행렬, 상기 제1 행렬, 상기 제2 행렬 및 상기 제3 행렬로 압축된 언어 모델을 생성하는, 전자 장치.The method according to claim 1,
The processor comprising:
Transforming the shared matrix into a first matrix, a second matrix and a third matrix using SVD (Singular Value Decomposition)
The first projection matrix, the second projection matrix, the first matrix, the second matrix, and the third matrix are subjected to the RNN learning by the basic data to generate the first projection matrix, the second projection matrix, Updating the elements of the matrix, the second matrix and the third matrix,
Wherein the element generates a compressed language model with the first projection matrix, the second projection matrix, the first matrix, the second matrix and the third matrix updated.
상기 프로세서는,
상기 복수의 문장 중 하나의 문장에 포함된 제1 워드에 대응되는 제1 벡터를 제1 랜덤 행렬에 기초하여 벡터 공간으로 매핑시킨 제1 데이터를 획득하고, 상기 문장에 포함되고 상기 제1 워드 다음의 제2 워드가 입력되면 상기 제2 워드에 대응되는 제2 벡터를 상기 제1 랜덤 행렬에 기초하여 상기 벡터 공간으로 매핑시킨 제2 데이터를 획득하며,
상기 제1 데이터 및 상기 제2 데이터에 기초하여 제3 데이터를 생성하고,
상기 제3 데이터를 제2 랜덤 행렬에 기초하여 복원 벡터를 획득하며, 상기 복원 벡터 및 상기 제2 워드 다음의 제3 워드에 대응되는 제3 벡터 간의 오차에 기초하여 상기 제1 랜덤 행렬 및 상기 제2 랜덤 행렬의 엘리먼트를 업데이트하여 학습하는, 전자 장치.The method according to claim 1,
The processor comprising:
Acquiring first data obtained by mapping a first vector corresponding to a first word included in one of the plurality of sentences into a vector space based on a first random matrix, A second vector corresponding to the second word is mapped to the vector space based on the first random matrix to obtain second data,
Generating third data based on the first data and the second data,
Based on an error between a third vector corresponding to the third word following the restoration vector and the second word, the first random matrix and the second random matrix based on the second random matrix, 2 The electronic device learns by updating the elements of the random matrix.
상기 프로세서는,
상기 복수의 문장 중 나머지 문장에 기초하여 상기 제1 랜덤 행렬 및 상기 제2 랜덤 행렬 각각의 엘리먼트를 업데이트하고,
상기 나머지 문장에 기초하여 엘리먼트가 업데이트된 상기 제1 랜덤 행렬 및 상기 제2 랜덤 행렬을 각각 상기 임베딩 행렬 및 상기 소프트맥스 행렬로서 상기 스토리지에 저장하는, 전자 장치.The method according to claim 6,
The processor comprising:
Update elements of each of the first random matrix and the second random matrix based on the remaining ones of the plurality of sentences,
Store the first random matrix and the second random matrix, whose elements are updated based on the remaining sentence, in the storage as the embedded matrix and the soft max matrix, respectively.
상기 임베딩 행렬 및 상기 소프트맥스 행렬의 전치 행렬은, 크기가 동일한, 전자 장치.The method according to claim 1,
Wherein the permutation matrix and the permutation matrix of the soft max matrix are the same in size.
임베딩 행렬로 이용되는 제1 프로젝션 행렬, 제1 행렬, 제2 행렬 및 제3 행렬 및 소프트맥스 행렬로 이용되는 제2 프로젝션 행렬, 상기 제1 행렬, 상기 제2 행렬 및 상기 제3 행렬을 포함하는 언어 모델이 저장된 스토리지; 및
제1 워드가 입력되면 상기 제1 워드에 대응되는 제1 벡터를 상기 제1 프로젝션 행렬, 상기 제1 행렬, 상기 제2 행렬 및 상기 제3 행렬에 기초하여 벡터 공간으로 매핑시킨 제1 데이터를 획득하고, 상기 제1 데이터를 상기 제2 프로젝션 행렬, 상기 제1 행렬, 상기 제2 행렬 및 상기 제3 행렬에 기초하여 제2 벡터를 획득하며, 상기 제2 벡터에 기초하여 추천 워드를 제공하는 프로세서;를 포함하는, 전자 장치.An electronic device for providing a recommendation word,
A first projection matrix used as an embedding matrix, a second projection matrix used as a first matrix, a second matrix and a third matrix and a soft max matrix, and a second projection matrix used as a matrix including the first matrix, the second matrix, Storage in which the language model is stored; And
When a first word is input, first data corresponding to the first word is mapped to a vector space based on the first projection matrix, the first matrix, the second matrix and the third matrix And obtaining a second vector based on the second projection matrix, the first matrix, the second matrix and the third matrix, and providing a recommendation word based on the second vector, And an electronic device.
상기 프로세서는,
상기 제1 워드가 입력된 후 제2 워드가 입력되면 상기 제2 워드에 대응되는 제3 벡터를 상기 제1 프로젝션 행렬, 상기 제1 행렬, 상기 제2 행렬 및 상기 제3 행렬에 기초하여 상기 벡터 공간으로 매핑시킨 제2 데이터를 획득하고,
상기 제1 데이터 및 상기 제2 데이터에 기초하여 제3 데이터를 생성하며,
상기 제3 데이터를 상기 제2 프로젝션 행렬, 상기 제1 행렬, 상기 제2 행렬 및 상기 제3 행렬에 기초하여 제4 벡터를 획득하며,
상기 제4 벡터에 기초하여 상기 추천 워드를 제공하는, 전자 장치.10. The method of claim 9,
The processor comprising:
When a second word is inputted after the first word is inputted, a third vector corresponding to the second word is calculated based on the first projection matrix, the first matrix, the second matrix and the third matrix, Acquiring second data mapped to the space,
Generating third data based on the first data and the second data,
Acquiring the third data based on the second projection matrix, the first matrix, the second matrix and the third matrix,
And provides the recommendation word based on the fourth vector.
상기 임베딩 행렬을 행렬의 크기가 동일한 제1 프로젝션 행렬(projection matrix) 및 공유 행렬의 곱으로 변환하고, 상기 소프트맥스 행렬의 전치 행렬을 행렬의 크기가 동일한 제2 프로젝션 행렬 및 상기 공유 행렬로 변환하는 단계; 및
상기 제1 프로젝션 행렬, 상기 제2 프로젝션 행렬 및 상기 공유 행렬을 상기 기본 데이터로 상기 RNN 학습하여 상기 제1 프로젝션 행렬, 상기 제2 프로젝션 행렬 및 상기 공유 행렬 각각의 엘리먼트를 업데이트하는 단계;를 포함하는 동작 방법.A language model of an electronic device in which a language model including an embedding matrix and a softmax matrix, which are RNN (Recurrent Neural Network) training, is stored as basic data including a plurality of sentences, An operating method for compressing,
Transforming the embedding matrix into a product of a first projection matrix and a shared matrix having the same matrix size, and transforming the transposed matrix of the soft-max matrix into a second projection matrix having the same matrix size and the shared matrix step; And
Updating the elements of the first projection matrix, the second projection matrix, and the shared matrix by RNN learning the first projection matrix, the second projection matrix, and the sharing matrix with the basic data How it works.
테스트 모듈에 기초하여 상기 제1 프로젝션 행렬, 상기 제2 프로젝션 행렬 및 상기 공유 행렬에 대한 워드 퍼플렉시티(word perplexity)를 산출하는 단계;
상기 워드 퍼플렉시티가 기설정된 값 이상이면 상기 공유 행렬보다 행렬의 크기(size)가 큰 새로운 공유 행렬을 획득하며, 상기 워드 퍼플렉시티가 상기 기설정된 값 미만이면 상기 공유 행렬보다 행렬의 크기가 작은 새로운 공유 행렬을 획득하는 단계; 및
상기 획득된 새로운 공유 행렬을 이용하여 상기 제1 프로젝션 행렬, 상기 제2 프로젝션 행렬 및 상기 공유 행렬을 재산출하는 단계;를 더 포함하는, 동작 방법.12. The method of claim 11,
Calculating a word perplexity for the first projection matrix, the second projection matrix and the shared matrix based on a test module;
Acquires a new shared matrix having a matrix size larger than the shared matrix if the word-polarity is greater than or equal to a predetermined value, and if the word-polarity is less than the predetermined value, Obtaining a small new share matrix; And
And shipping the first projection matrix, the second projection matrix and the shared matrix using the obtained new shared matrix.
상기 테스트 모듈에 기초하여 상기 임베딩 행렬 및 상기 소프트맥스 행렬에 대한 기준 워드 퍼플렉시티를 산출하는 단계; 및
상기 기준 워드 퍼플렉시티에 기초하여 상기 기설정된 값을 결정하는 단계;를 더 포함하는, 동작 방법.13. The method of claim 12,
Computing a reference wordperformance for the embedded matrix and the soft-max matrix based on the test module; And
And determining the predetermined value based on the reference word parity.
상기 재산출하는 단계는,
상기 워드 퍼플렉시티가 상기 기설정된 값 미만인 복수의 공유 행렬 중 행렬의 크기가 가장 작은 공유 행렬로 상기 제1 프로젝션 행렬, 상기 제2 프로젝션 행렬 및 상기 공유 행렬을 재산출하고,
재산출된 상기 제1 프로젝션 행렬, 상기 제2 프로젝션 행렬 및 상기 공유 행렬로 압축된 언어 모델을 생성하는 단계;를 더 포함하는, 동작 방법.14. The method of claim 13,
The step of shipment of the property includes:
The first projection matrix, the second projection matrix, and the shared matrix to a shared matrix having the smallest matrix size among the plurality of shared matrices having the word-polarity less than the predetermined value,
Generating the re-computed first projection matrix, the second projection matrix and the compressed language model with the shared matrix.
SVD(Singular Value Decomposition)를 이용하여 상기 공유 행렬을 제1 행렬, 제2 행렬 및 제3 행렬로 변환하는 단계;
상기 제1 프로젝션 행렬, 상기 제2 프로젝션 행렬, 상기 제1 행렬, 상기 제2 행렬 및 상기 제3 행렬을 상기 기본 데이터로 상기 RNN 학습하여 상기 제1 프로젝션 행렬, 상기 제2 프로젝션 행렬, 상기 제1 행렬, 상기 제2 행렬 및 상기 제3 행렬 각각의 엘리먼트를 업데이트하는 단계; 및
상기 엘리먼트가 업데이트된 상기 제1 프로젝션 행렬, 상기 제2 프로젝션 행렬, 상기 제1 행렬, 상기 제2 행렬 및 상기 제3 행렬로 압축된 언어 모델을 생성하는 단계;를 더 포함하는, 동작 방법.12. The method of claim 11,
Transforming the shared matrix into a first matrix, a second matrix and a third matrix using SVD (Singular Value Decomposition);
The first projection matrix, the second projection matrix, the first matrix, the second matrix, and the third matrix are subjected to the RNN learning by the basic data to generate the first projection matrix, the second projection matrix, Updating elements of the matrix, the second matrix and the third matrix; And
Generating a language model compressed with the first projection matrix, the second projection matrix, the first matrix, the second matrix and the third matrix with the element updated.
상기 복수의 문장 중 하나의 문장에 포함된 제1 워드에 대응되는 제1 벡터를 제1 랜덤 행렬에 기초하여 벡터 공간으로 매핑시킨 제1 데이터를 획득하는 단계;
상기 문장에 포함되고 상기 제1 워드 다음의 제2 워드가 입력되면 상기 제2 워드에 대응되는 제2 벡터를 상기 제1 랜덤 행렬에 기초하여 상기 벡터 공간으로 매핑시킨 제2 데이터를 획득하는 단계;
상기 제1 데이터 및 상기 제2 데이터에 기초하여 제3 데이터를 생성하는 단계;
상기 제3 데이터를 제2 랜덤 행렬에 기초하여 복원 벡터를 획득하는 단계; 및
상기 복원 벡터 및 상기 제2 워드 다음의 제3 워드에 대응되는 제3 벡터 간의 오차에 기초하여 상기 제1 랜덤 행렬 및 상기 제2 랜덤 행렬의 엘리먼트를 업데이트하여 학습하는 단계;를 더 포함하는, 동작 방법.12. The method of claim 11,
Obtaining first data obtained by mapping a first vector corresponding to a first word included in one of the plurality of sentences into a vector space based on a first random matrix;
Acquiring second data, which is included in the sentence and is mapped to the vector space based on the first random matrix, when the second word following the first word is input, the second vector corresponding to the second word;
Generating third data based on the first data and the second data;
Obtaining the restored vector based on the third data and a second random matrix; And
Further comprising: updating and learning elements of the first random matrix and the second random matrix based on an error between the restoration vector and a third vector corresponding to a third word after the second word Way.
상기 복수의 문장 중 나머지 문장에 기초하여 상기 제1 랜덤 행렬 및 상기 제2 랜덤 행렬 각각의 엘리먼트를 업데이트하는 단계; 및
상기 나머지 문장에 기초하여 엘리먼트가 업데이트된 상기 제1 랜덤 행렬 및 상기 제2 랜덤 행렬을 각각 상기 임베딩 행렬 및 상기 소프트맥스 행렬로서 저장하는 단계;를 더 포함하는, 동작 방법.17. The method of claim 16,
Updating elements of each of the first random matrix and the second random matrix based on the remaining ones of the plurality of sentences; And
And storing the first random matrix and the second random matrix in which an element is updated based on the remaining sentence as the embedded matrix and the soft max matrix, respectively.
상기 임베딩 행렬 및 상기 소프트맥스 행렬의 전치 행렬은, 크기가 동일한, 동작 방법.12. The method of claim 11,
Wherein the permutation matrix and the permutation matrix of the soft max matrix are of equal magnitude.
제1 워드가 입력되면 상기 제1 워드에 대응되는 제1 벡터를 상기 제1 프로젝션 행렬, 상기 제1 행렬, 상기 제2 행렬 및 상기 제3 행렬에 기초하여 벡터 공간으로 매핑시킨 제1 데이터를 획득하는 단계;
상기 제1 데이터를 상기 제2 프로젝션 행렬, 상기 제1 행렬, 상기 제2 행렬 및 상기 제3 행렬에 기초하여 제2 벡터를 획득하는 단계; 및
상기 제2 벡터에 기초하여 추천 워드를 제공하는 단계;를 포함하는, 동작 방법.A first projection matrix used as an embedding matrix, a second projection matrix used as a first matrix, a second matrix and a third matrix and a soft max matrix, and a second projection matrix used as a matrix including the first matrix, the second matrix, An operating method for providing a recommendation word of an electronic device in which a language model is stored,
When a first word is input, first data corresponding to the first word is mapped to a vector space based on the first projection matrix, the first matrix, the second matrix and the third matrix ;
Obtaining the first data based on the second projection matrix, the first matrix, the second matrix and the third matrix; And
And providing a recommendation word based on the second vector.
상기 제1 워드가 입력된 후 제2 워드가 입력되면 상기 제2 워드에 대응되는 제3 벡터를 상기 제1 프로젝션 행렬, 상기 제1 행렬, 상기 제2 행렬 및 상기 제3 행렬에 기초하여 상기 벡터 공간으로 매핑시킨 제2 데이터를 획득하는 단계;
상기 제1 데이터 및 상기 제2 데이터에 기초하여 제3 데이터를 생성하는 단계;
상기 제3 데이터를 상기 제2 프로젝션 행렬, 상기 제1 행렬, 상기 제2 행렬 및 상기 제3 행렬에 기초하여 제4 벡터를 획득하는 단계; 및
상기 제4 벡터에 기초하여 상기 추천 워드를 제공하는 단계;를 더 포함하는, 동작 방법.20. The method of claim 19,
When a second word is inputted after the first word is inputted, a third vector corresponding to the second word is calculated based on the first projection matrix, the first matrix, the second matrix and the third matrix, Acquiring second data mapped to the space;
Generating third data based on the first data and the second data;
Obtaining the third data based on the second projection matrix, the first matrix, the second matrix and the third matrix; And
And providing the recommendation word based on the fourth vector.
Priority Applications (4)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
US15/888,442 US10691886B2 (en) | 2017-03-09 | 2018-02-05 | Electronic apparatus for compressing language model, electronic apparatus for providing recommendation word and operation methods thereof |
PCT/KR2018/001611 WO2018164378A1 (en) | 2017-03-09 | 2018-02-06 | Electronic apparatus for compressing language model, electronic apparatus for providing recommendation word and operation methods thereof |
CN201880005774.XA CN110168542B (en) | 2017-03-09 | 2018-02-06 | Electronic device for compressing language model, electronic device for providing recommended word, and operating method thereof |
EP18763492.8A EP3577571A4 (en) | 2017-03-09 | 2018-02-06 | Electronic apparatus for compressing language model, electronic apparatus for providing recommendation word and operation methods thereof |
Applications Claiming Priority (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
US201762469089P | 2017-03-09 | 2017-03-09 | |
US62/469,089 | 2017-03-09 |
Publications (2)
Publication Number | Publication Date |
---|---|
KR20180103671A true KR20180103671A (en) | 2018-09-19 |
KR102488338B1 KR102488338B1 (en) | 2023-01-13 |
Family
ID=63719251
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
KR1020170147922A KR102488338B1 (en) | 2017-03-09 | 2017-11-08 | Electronic apparatus for compressing language model, electronic apparatus for providing recommendation word and operation methods thereof |
Country Status (3)
Country | Link |
---|---|
EP (1) | EP3577571A4 (en) |
KR (1) | KR102488338B1 (en) |
CN (1) | CN110168542B (en) |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2020045915A1 (en) | 2018-08-31 | 2020-03-05 | 주식회사 엘지화학 | System and method for correcting current value of shunt resistor |
KR20200133609A (en) * | 2019-05-20 | 2020-11-30 | 에스케이텔레콤 주식회사 | Memory network apparatus and deducing method using the same |
US11675973B2 (en) | 2020-01-31 | 2023-06-13 | Samsung Electronics Co., Ltd. | Electronic device and operation method for embedding an input word using two memory operating speeds |
Families Citing this family (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US11741356B2 (en) * | 2019-02-08 | 2023-08-29 | Korea Advanced Institute Of Science & Technology | Data processing apparatus by learning of neural network, data processing method by learning of neural network, and recording medium recording the data processing method |
CN110781690B (en) * | 2019-10-31 | 2021-07-13 | 北京理工大学 | Fusion and compression method of multi-source neural machine translation model |
CN111597825B (en) * | 2020-05-13 | 2021-07-23 | 北京字节跳动网络技术有限公司 | Voice translation method and device, readable medium and electronic equipment |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20140372112A1 (en) * | 2013-06-18 | 2014-12-18 | Microsoft Corporation | Restructuring deep neural network acoustic models |
JP2016212273A (en) * | 2015-05-11 | 2016-12-15 | 国立研究開発法人情報通信研究機構 | Recurrent type neural network learning method, computer program for the same, and voice recognition device |
Family Cites Families (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP5410355B2 (en) * | 2010-04-13 | 2014-02-05 | 富士フイルム株式会社 | Matrix generation apparatus, method, program, and information processing apparatus |
KR102167719B1 (en) * | 2014-12-08 | 2020-10-19 | 삼성전자주식회사 | Method and apparatus for training language model, method and apparatus for recognizing speech |
KR102305584B1 (en) * | 2015-01-19 | 2021-09-27 | 삼성전자주식회사 | Method and apparatus for training language model, method and apparatus for recognizing language |
CN104636317A (en) * | 2015-03-09 | 2015-05-20 | 湘潭大学 | Method for optimizing interactive projection measurement matrix based on feature value decomposition |
CN106407211B (en) * | 2015-07-30 | 2019-08-06 | 富士通株式会社 | The method and apparatus classified to the semantic relation of entity word |
-
2017
- 2017-11-08 KR KR1020170147922A patent/KR102488338B1/en active IP Right Grant
-
2018
- 2018-02-06 EP EP18763492.8A patent/EP3577571A4/en not_active Ceased
- 2018-02-06 CN CN201880005774.XA patent/CN110168542B/en active Active
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20140372112A1 (en) * | 2013-06-18 | 2014-12-18 | Microsoft Corporation | Restructuring deep neural network acoustic models |
JP2016212273A (en) * | 2015-05-11 | 2016-12-15 | 国立研究開発法人情報通信研究機構 | Recurrent type neural network learning method, computer program for the same, and voice recognition device |
Non-Patent Citations (1)
Title |
---|
Ofir Press외 1명, "Using the Output Embedding to Improve Language Models", PROCEEDINGS OF THE 15TH CONFERENCE OF THE EUROPEAN CHAPTER OF THE ASSOCIATION FOR COMPUTATIONAL LINGUISTICS: VOLUME2, SHORT PAP * |
Cited By (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2020045915A1 (en) | 2018-08-31 | 2020-03-05 | 주식회사 엘지화학 | System and method for correcting current value of shunt resistor |
KR20200133609A (en) * | 2019-05-20 | 2020-11-30 | 에스케이텔레콤 주식회사 | Memory network apparatus and deducing method using the same |
KR20210134566A (en) * | 2019-05-20 | 2021-11-10 | 에스케이텔레콤 주식회사 | Memory network apparatus and deducing method using the same |
US11675973B2 (en) | 2020-01-31 | 2023-06-13 | Samsung Electronics Co., Ltd. | Electronic device and operation method for embedding an input word using two memory operating speeds |
Also Published As
Publication number | Publication date |
---|---|
CN110168542A (en) | 2019-08-23 |
EP3577571A4 (en) | 2020-02-26 |
KR102488338B1 (en) | 2023-01-13 |
CN110168542B (en) | 2023-11-24 |
EP3577571A1 (en) | 2019-12-11 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US10691886B2 (en) | Electronic apparatus for compressing language model, electronic apparatus for providing recommendation word and operation methods thereof | |
KR102488338B1 (en) | Electronic apparatus for compressing language model, electronic apparatus for providing recommendation word and operation methods thereof | |
US10671889B2 (en) | Committed information rate variational autoencoders | |
KR102380494B1 (en) | Image processing apparatus and method | |
CN112257858B (en) | Model compression method and device | |
CN111368993B (en) | Data processing method and related equipment | |
CN111816159B (en) | Language identification method and related device | |
US20240029436A1 (en) | Action classification in video clips using attention-based neural networks | |
KR20190105745A (en) | Electronic apparatus and control method thereof | |
US20210279589A1 (en) | Electronic device and control method thereof | |
US11568254B2 (en) | Electronic apparatus and control method thereof | |
KR20210136706A (en) | Electronic apparatus and method for controlling thereof | |
CN113948060A (en) | Network training method, data processing method and related equipment | |
CN113421547A (en) | Voice processing method and related equipment | |
CN114882862A (en) | Voice processing method and related equipment | |
CN116737895A (en) | Data processing method and related equipment | |
US10997947B2 (en) | Electronic device and control method thereof | |
WO2024046144A1 (en) | Video processing method and related device thereof | |
CN115292439A (en) | Data processing method and related equipment | |
US11475281B2 (en) | Electronic apparatus and control method thereof | |
CN116306612A (en) | Word and sentence generation method and related equipment | |
KR102663654B1 (en) | Adaptive visual speech recognition | |
CN116579403A (en) | Data processing method and related equipment | |
CN117852603A (en) | Task information acquisition method and related equipment | |
CN118366428A (en) | Data processing method, electronic device and computer program product |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
A201 | Request for examination | ||
E902 | Notification of reason for refusal | ||
E701 | Decision to grant or registration of patent right | ||
GRNT | Written decision to grant |