The particle-in-cell (PIC) method is powerful for simulating plasma kinetic processes. However, PIC simulations are usually computationally expensive, and improving the computational efficiency is essential for expanding their capabilities. Adaptive mesh refinement (AMR) is an important technique that can be applied to accelerate PIC simulations. In this paper, we introduce a novel adaptive mesh refinement (AMR) algorithm that is implemented for a semi-implicit electromagnetic particle-in-cell (PIC) code. Our approach supports different refinement ratios as well as multiple refinement levels. The electric field solver is carefully designed to minimize artifacts at interfaces of different levels, and we introduce an algorithm to reduce errors in Gauss's law across all levels. To maintain a uniform particle distribution, which is crucial for achieving high computational efficiency, particle splitting and merging techniques are integrated into the code. We validate our algorithm with several tests, including a two-dimensional double current sheet reconnection test, that show accurate solutions on the AMR grid with considerable speed-up relative to a uniform high-resolution grid.