본 연구에서는 자연어 처리에 좋은 성능을 보인다고 알려진 Transformer와 제 4대 동형암호인 CKKS를 사용하여 프라이버시 보존 기계 번역 서비스인 HE-Transformer를 구현한다. 우리는 구현 과정에서 번역 대상 정보를 가지고 있는 클라이언트와 번역 서비스 제공자가 단어들의 색인(index) 정보를 공유한다고 가정한다. 이러한 가정하에 HE-Transformer 수행을 위한 각 단계를 암호화된 입력 문장이 들어왔을 경우, 효율적인 번역을 수행하기 위하여 다양한 동형암호 기반 방법을 제안한다. HE-Transformer는 색인이 암호화되어 있어 색인을 직접적으로 사용할 수 없다. 그래서 우리는 사용자가 번역하고자 하는 단어 색인을 특별한 방법으로 인코딩한다. 인코딩한 값은 암호화해 클라우드에 보낸다. 사용자가 보낸 번역 하고자 하는 단어의 색인 암호문 또한 특별한 방법으로 평문 다항식 토큰 임베딩에 매칭한다. 이 방법을 통해 우리는 간접적으로 색인 정보를 활용한다. HE-Transformer는 Softmax와 ReLU와 같은 비선형 활성화 함수를 근사하거나 연산을 회피한다. Transformer에는 Softmax와 ReLU와 같은 비선형 활성화 함수가 있다. 하지만 CKKS는 덧셈과 곱셈만 지원하기 때문에 HE-Transformer에서는 Softmax나 ReLU를 직접 계산할 수 없다. 그래서 HE-Transformer에서는 다항식 근사를 통해서 이러한 활성화 함수를 근사하거나 연산을 회피한다. 우리는 가장 접근이 쉬운 제곱 함수를 통해 활성화 함수 ReLU를 대체한다. 그리고 MHA 블록에서의 Softmax는 사용하지 않고 Logit 값으로만 계산하며 디코더가 끝난 이후에 수행하는 Softmax는 Logit 값의 최대값을 찾는 것으로 Softmax 연산을 회피한다. 또한 위와 같은 이유로 제곱근을 사용할 수 없다. 그래서 제곱근은 제곱근의 역수를 근사해 사용한다. 우리는 HE-Transformer를 구현하고 번역 성능과 수행 시간을 측정한다. 번역 성능 측정을 위해 학습과 추론에 사용한 데이터 셋은 Multi30K이며 그중에서 우리는 두 번 이상 등장한 단어들로 구성된 임베딩과 SOS 토큰 및 EOS 토큰을 포함한 15단어 이하로 구성된 문장들을 사용한다. HE-Transformer의 성능 비교를 위해 HE-Transformer와 Original Transformer의 성능을 비교 분석한다. 그 결과는 HE-Transformer의 BLEU Score의 평균은 29.44, 표준편차 0.37이며, Original Transformer는 BLEU Score의 평균은 32.68, 표준편차 0.39로 HE-Transformer는 Original Transformer 대비 성능이 약 11% 하락했다. 이는 HE-Transformer의 성능을 향상하기 위해 사용하였던 다양한 근사 및 비선형함수 회피로 인한 결과라고 추론할 수 있다. 동일한 계산 환경에서 HE-Transformer와 Original Transformer이 기계 번역 추론 수행 시간을 측정했다. HE-Transformer가 8시간 38분 59초로써 Original Transformer 0.04초에 비하여 778000 배 느리며, 이는 일반적으로 알려진 동형암호 사용으로 인한 성능 하락 (1만배~10만배) 보다 좀 더 많은 수준이다. 이는 전체 수행 시간 중 근사함수 중 동일한 암호문 값이 있는 슬롯일 경우 0을 반환하는 DiscreteEqualZero 함수, 두 값을 비교하여 큰 값이면 1의 암호문을 반환하는 Compare 함수, 그리고 제곱근의 역수를 반환하는 InverseSquareRoot 함수 등의 수행 시간이 1회에 수십 초가 걸리는 것에 기인한다. 결론적으로 제안 HE-Transformer는 아직 실사용에 쓰일 정도의 성능은 나오지 않는다. 그러나 제안한 성능 향상 방법들의 적용과 향후 CKKS에 대한 연구가 더 활발해진다면 많은 성능 향상이 예상된다. 본 연구를 바탕으로 더 많은 성능 향상이 이루어진다면 중요한 정보가 오고 가는 기업 및 국가 간 서류 번역 시 정보 누출로 인한 치명적 문제를 차단하는 것에 공헌할 것으로 기대된다.
In this study, we implement HE-Transformer, a privacy preservation machine translation service, using Transformer, known to perform well in natural language processing, and CKKS, the fourth homomorphic encryption. We assume that in the implementation process, clients and translation service providers with translation target information share index information of words. Under this assumption, when an encrypted input sentence is received for each step for execution HE-Transformer, various homomorphic encryption-based methods are proposed to execution efficient translation. He-Transformer cannot directly use the index because the index is encrypted. So we encode the word index that the clients wants to translate in a special way. The encoded value is encrypted and sent to the cloud. The index ciphertext of the word to be translated sent by the user also matches the plaintext polynomial token embedding in a special way. Through this method, we indirectly utilize index information. HE-Transformer approximates nonlinear activation functions such as Softmax and ReLU or avoids computation. Transformer has nonlinear activation functions such as Softmax and ReLU. However, since CKKS only supports addition and multiplication, HE-Transformer cannot directly calculate Softmax or ReLU. Therefore, HE-Transformer approximates these activation functions through polynomial approximation or avoids computation. We replace the activation function ReLU with the most accessible square function. In addition, Softmax in the MHA block is not used, but is calculated only as a Logit value, and Softmax execution after the decoder is execution to find the maximum value of the Logit value, avoiding the Softmax operation. In addition, square roots cannot be used for the above reasons. So the square root is approximated by the reciprocal of the square root. We implement HE-Transformer and measure translation performance and execution time. The dataset used for learning and reasoning to measure translation performance is Multi30K, of which we use embeddings consisting of words that have appeared more than once, and sentences consisting of 15 words or less, including SOS tokens and EOS tokens. To compare the performance of HE-Transformer, we compare and analyze the performance of HE-Transformer and Original Transformer. As a result, HE-Transformer''s BLEU Score average was 29.44, standard deviation was 0.37, and BLEU Score average was 32.68 and standard deviation was 0.39, and HE-Transformer''s performance decreased by about 11% compared to the original transformer. It can be inferred that this is the result of avoidance of various approximations and nonlinear functions used to improve the performance of HE-Transformer. HE-Transformer and Original Transformer measured machine translation inference time in the same computational environment. HE-Transformer is 8 hours 38 minutes 59 seconds, 778,000 times slower than Original Transformer 0.04 seconds, which is slightly higher than the generally known decline in performance (10,000 to 100,000 times) due to the use of homomorphic encryption. This is due to the fact that the execution time takes tens of seconds once, such as the DiscreteEqualZero function that returns 0 for slots with the same ciphertext value among the approximation functions, the Compare function that returns the ciphertext of 1 if the two values are large, and the InverseSquareRoot function that returns the reciprocal of the square root. In conclusion, the proposed HE-Transformer has not yet produced enough performance for practical use. However, if the application of the proposed performance improvement methods and research on CKKS become more active in the future, many performance improvements are expected. If more performance improvements are made based on this study, it is expected to contribute to blocking fatal problems caused by information leakage when translating documents between companies and countries where important information comes and goes.
목차
요약 ⅰ표 목차 ⅴ그림목차 ⅴI. 서 론 1II. 배경 지식 41. Transformer 42. CKKS 9III. 관련 연구 15IV. 연구 동기 18V. 제안 방법 201. 전체구조 222. 세부구조 242.1 Matching index 252.2 Inner product 312.3 Multi-Head Attention (MHA) 352.4 Add&Norm 382.5 Feed Forward 402.6 Linear 422.7 Max 422.8 Index return 442.9 Max index 452.10 Matching embedding 45Ⅵ. 성능 평가 471. 성능 평가 환경 472. 데이터 473. HE-Transformer 성능 평가 484. 성능 향상 방향 51Ⅶ. 결론 53참고문헌 55영문초록(Abstract) 60감사의 글